- ハッシュマップのキーをpqに格納し、ポーリング時にハッシュマップの値を比較します。
- #743
Map<Integer, Integer> map = new HashMap<>();
PriorityQueue<Integer> pq = new PriorityQueue<>((n1, n2) -> map.get(n1) - map.get(n2));
- 二次元配列は、各配列の最初の要素で昇順にソートされます。
- #56
Arrays.sort(intervals, (int[] a, int[] b) -> {
return a[0] - b[0];
});
- 原点からの距離による平面上の点の順序付け
- #379
int[][] res = new int[k][2];
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> b[0] * b[0] + b[1] * b[1] - a[0] * a[0] - a[1] * a[1]);