class Solution { public: vector<int> GetLeastNumbers_Solution(vector<int> input, int k) { vector<int> result; int len = input.size(); if(len==0 || k>len) return result; sort(input.begin(),input.end()); result.assign(input.begin(), input.begin()+k); return result; } };
原文:https://www.cnblogs.com/loyolh/p/12342989.html