class Solution {
public int[] kthSmallestPrimeFraction(int[] arr, int k) {
int n = arr.length;
ArrayList<int[]> score_lst = new ArrayList<>();
for (int i = 0; i < n; i++) {
for (int j = i+1;j<n;j++){
score_lst.add(new int[]{arr[i],arr[j]});
}
}
Collections.sort(score_lst, new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[0]*o2[1]-o2[0]*o1[1];
}
});
return score_lst.get(k-1);
}
}
自定义排序,但是这个为什么升序这么写我也不是很理解,等我理解了再写过来吧。