题解 | #最小的K个数#

最小的K个数

http://www.nowcoder.com/questionTerminal/6a296eb82cf844ca8539b57c23e6e9bf

class Solution {
public:
vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
vector<int> output;
if(input.empty() || k<0 || input.size()<k)
return output;
sort(input.begin(),input.end());
int i=0;
while(i<k)
{
output.push_back(input[i]);
i++;
}
return output;
}
};</int></int></int>

全部评论

相关推荐

11-11 16:40
已编辑
门头沟学院 人工智能
不知道怎么取名字_:这个有点不合理了,相当于已经毕业了,但还是没转正,这不就是白嫖
点赞 评论 收藏
分享
11-06 23:30
已编辑
华中师范大学 后端工程师
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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