如何在给定的数组中找到第二、第三、第四或第五个值?
如果我们在Python中使用
max()
函数,与此函数相关的复杂度是什么?
def nth_largest(li,n):
li.remove(max(li))
print max(ele) //will give me the second largest
#how to make a general algorithm to find the 2nd,3rd,4th highest value
#n is the element to be found below the highest value
[1,2,2]
,你想要作为第二大元素的是什么?1
还是2
? - DSM