python做法| #最小的K个数#
最小的K个数
http://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf
# -*- coding:utf-8 -*- class Solution: def GetLeastNumbers_Solution(self, tinput, k): # write code here n = len(tinput) if n<=k:return tinput if not k: return [] res = tinput[0:k] maxi = res.index(max(res)) for i in range(k,n): if tinput[i]<res[maxi]:res[maxi] = tinput[i];maxi = res.index(max(res)) return res
大佬们帮我看看这个算是复杂度达到标准吗