1
class Solution {
2
public int[][] reconstructQueue(int[][] people) {
3
List<int[]> result = new ArrayList<>(); // return value
4

5
Arrays.sort(
6
people,
7
(a, b) -> {
8
int x = Integer.compare(b[0], a[0]);
9
if (x == 0) return Integer.compare(a[1], b[1]);
10
else return x;
11
});
12

13
for (int[] p : people) result.add(p[1], p);
14

15
return result.toArray(new int[people.length][2]);
16
}
17
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0