题解 | #最小的K个数#
最小的K个数
http://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf
排序后在截取
function GetLeastNumbers_Solution(input, k)
{
// write code here
if(k < 1 || k > input.length) {
return []
}
input.sort((a,b) => a - b)
return input.slice(0,k)
}
module.exports = {
GetLeastNumbers_Solution : GetLeastNumbers_Solution
};