题解 | #最小的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
}
全部评论

相关推荐

09-04 00:41
中山大学 C++
鼠鼠能上岸吗:进行中是秋招大项目进行中,你还可以选别的岗位;已结束是这个岗位流程结束了;筛选中就是在简历筛选环节没hr捞
投递美团等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务