Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf92d1d6

Browse files
authored
Update Queue Reconstruction By Height.java
1 parent6d45f98 commitf92d1d6

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
classSolution {
22
publicint[][]reconstructQueue(int[][]people) {
3-
Arrays.sort(people,newComparator<int[]>(){
4-
publicintcompare(int[]o1,int[]o2) {
5-
intc =o2[0] -o1[0];
6-
if (c !=0) {
7-
returnc;
8-
}
9-
returno1[1] -o2[1];
10-
}
11-
});
12-
System.out.println();
13-
List<int[]>list =newArrayList<>();
3+
Arrays.sort(people, (o1,o2) ->o1[0] ==o2[0] ?o1[1] -o2[1] :o2[0] -o1[0]);
4+
List<int[]>result =newArrayList<>();
145
for (int[]p :people) {
15-
list.add(p[1],p);
6+
result.add(p[1],p);
167
}
178
intn =people.length;
18-
returnlist.toArray(newint[n][2]);
9+
returnresult.toArray(newint[n][2]);
1910
}
2011
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp