和排序有关得数组,就会想到用sorted()或者sort(),不过前者有返回值,后者是直接在原列表操作,没有返回值
# -*- coding:utf-8 -*-
class Solution:
def GetLeastNumbers_Solution(self, tinput, k):
# write code here
return sorted(tinput)[:k]
class Solution:
def GetLeastNumbers_Solution(self, tinput, k):
# write code here
return sorted(tinput)[:k]