N*8
2 楼
Given a array of positive integers, find all possible triangle triplets that
can be formed from this array.
eg: 9 8 10 7
ans: 9 8 10, 9 8 7, 9 10 7, 7 8 10
Note : array not sorted, there is no limit on the array length
geeks4geeks有类似的,但是只是求三角形个数的,能用n^2事件复杂度解出来。但是如
果求所有的三边的输出,感觉还是要n^3。请教大家的优化方法。
can be formed from this array.
eg: 9 8 10 7
ans: 9 8 10, 9 8 7, 9 10 7, 7 8 10
Note : array not sorted, there is no limit on the array length
geeks4geeks有类似的,但是只是求三角形个数的,能用n^2事件复杂度解出来。但是如
果求所有的三边的输出,感觉还是要n^3。请教大家的优化方法。
h*e
3 楼
我日,被骗了,今天才9号。
w*a
4 楼
感觉就是3 sum变种题
m*t
5 楼
白忙活了,是明天。
r*7
6 楼
要是需要输出所有的话,必然要n^3吧,extreme的case是所有的组合都是valid的,就
必然有n^3个结果啊
that
【在 N*****8 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: Given a array of positive integers, find all possible triangle triplets that
: can be formed from this array.
: eg: 9 8 10 7
: ans: 9 8 10, 9 8 7, 9 10 7, 7 8 10
: Note : array not sorted, there is no limit on the array length
: geeks4geeks有类似的,但是只是求三角形个数的,能用n^2事件复杂度解出来。但是如
: 果求所有的三边的输出,感觉还是要n^3。请教大家的优化方法。
必然有n^3个结果啊
that
【在 N*****8 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: Given a array of positive integers, find all possible triangle triplets that
: can be formed from this array.
: eg: 9 8 10 7
: ans: 9 8 10, 9 8 7, 9 10 7, 7 8 10
: Note : array not sorted, there is no limit on the array length
: geeks4geeks有类似的,但是只是求三角形个数的,能用n^2事件复杂度解出来。但是如
: 果求所有的三边的输出,感觉还是要n^3。请教大家的优化方法。
L*1
9 楼
chi
G*n
10 楼
sort + two pointer + combination
w*a
14 楼
怎么弄都还是O(n^3)吧
相关阅读
Seeking Quant/Software Developers (转载)G家team match求捞为什么总是我?【2020年9月1日收市后对QQQ的谷底高峰预测。看跌】 (转载)Re: 中概股这么炒作,SEC不管吗? (转载)华人大佬看见华人就想招是吗FB面试被reject可以appeal吗?中国公司优待老美是普遍现象吧看美剧学英语 – The office | 办公室第一季第二集精讲解析 (下)Re: 这几门课应该怎么翻译 (转载)听说巨硬有确诊的了【金融绝对是夕阳行业。国内滞后,还在迷信追捧】 (转载)【周末马前炮。近千米股暴利预测。一切在预料中】 (转载)【太不可思议了。大家说说这是什么狗屁罪名啊?】 (转载)为什么大公司经常开出3-5月的contractor职位Google will invest $10 billion in India over the next few y (转载)F1 OPT转J1行业二线 一些很奇特的地方有unlawful presence和非法打工,H1B cp能通过吗?【2020年11月5日收市后对1100个米股的预测-多数看跌】 (转载)