no dup ... so you can sort first -> O(n*Log(n)) Then start picking from smallest. Total complexity O(n) + O(n*Log(n)), still the same as O(n*Log(n))
c*t
15 楼
排玩序后,也不可能用O(n)找出m个数 虽然和背包问题不同,但还是可以用DP解, O(m*n*s) time
【在 o**********t 的大作中提到】 : no dup ... so you can sort first -> O(n*Log(n)) : Then start picking from smallest. : Total complexity O(n) + O(n*Log(n)), still the same as O(n*Log(n))