import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class Solution {
public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) {
ArrayList<Integer> re = new ArrayList<>();
if (input == null || input.length == 0) return re;
for (int i = 0; i < input.length; i++) {
re.add(input[i]);
}
// 排序
re.sort(Comparator.comparing(Integer::valueOf));
// 获取最小k个数
List<Integer> li = re.subList(0, k);
re = new ArrayList<>();
re.addAll(li);
return re;
}
}
#剑指offr#