题解 | #最小的K个数#
最小的K个数
https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf
func GetLeastNumbers_Solution( input []int , k int ) []int {
// write code here
sort.Ints(input)
res := make([]int,k)
for i:=0;i<len(input);i++{
if i+1>k{
break
}
res[i] = input[i]
}
return res
}
// write code here
sort.Ints(input)
res := make([]int,k)
for i:=0;i<len(input);i++{
if i+1>k{
break
}
res[i] = input[i]
}
return res
}