题解 | #最小的K个数#
最小的K个数
http://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf
public:
vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
vector<int> result;
sort(input.begin(),input.end());
int i,count=0;
for(i=0;i<=input.size()-1;i++){
if(count==k){
break;
}
result.push_back(input[i]);
count+=1;
}
return result;
}
};