题解 | #最小的K个数#
最小的K个数
https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf
import java.util.*; import java.util.ArrayList; public class Solution { public ArrayList<Integer> GetLeastNumbers_Solution(int[] input, int k) { ArrayList<Integer> r = new ArrayList<>(); Arrays.stream(input).sorted().limit(k).forEach(x-> r.add(x)); return r; } }