Get Least Numbers 2021-06-25 08:13
public int[] getLeastNumbers(int[] arr, int k) {
Arrays.sort(arr);
int[] res = new int[k];
for (int i = 0; i < k; i++) {
res[i] = arr[i];
}
return res;
}
Runtime | Memory |
---|---|
8 ms | 39.7 MB |
EOF