计数排序
class Solution {
public int[] getLeastNumbers(int[] arr, int k) {
if(k == 0 || arr.length == 0) return new int[0];
int[] count = new int[10001];
for(int num : arr) count[num]++;
int[] result = new int[k];
int index = 0;
for(int i = 0; i < count.length; i++){
while(count[i]-- > 0 && index < k) result[index++] = i;
if(index == k) break;
}
return result;
}
}