leetcode 40.最小的K个数
输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。法一:复制给另一个数组import java.util.*;class Solution { public int[] getLeastNumbers(int[] arr, int k) { Arrays.sort(arr); int[] result = new int[k]; System.arraycopy
原创
2020-09-09 17:17:50 ·
101 阅读 ·
0 评论