Skip to content

Commit 4ffdfa1

Browse files
authored
Create Solution.java
1 parent 8718f23 commit 4ffdfa1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int[][] reconstructQueue(int[][] people) {
3+
Arrays.sort(people, (o1, o2) -> o1[0] != o2[0] ? Integer.compare(o2[0], o1[0]) : Integer.compare(o1[1], o2[1]));
4+
List<int[]> res = new ArrayList<>(people.length);
5+
for (int[] p : people) {
6+
res.add(p[1], p);
7+
}
8+
return res.toArray(new int[res.size()][]);
9+
}
10+
}

0 commit comments

Comments
 (0)