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

Commit01f14ae

Browse files
authored
Update 0406.根据身高重建队列.md
更新Java:使用lambda
1 parente70378f commit01f14ae

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

‎problems/0406.根据身高重建队列.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,10 @@ Java:
188188
```java
189189
classSolution {
190190
publicint[][]reconstructQueue(int[][]people) {
191-
Arrays.sort(people,newComparator<int[]>() {
192-
@Override
193-
publicintcompare(int[]o1,int[]o2) {
194-
if (o1[0]!= o2[0]) {
195-
returnInteger.compare(o2[0],o1[0]);
196-
}else {
197-
returnInteger.compare(o1[1],o2[1]);
198-
}
199-
}
191+
// 身高从大到小排(身高相同k小的站前面)
192+
Arrays.sort(people, (a, b)-> {
193+
if (a[0]== b[0])return a[1]- b[1];
194+
return b[0]- a[0];
200195
});
201196

202197
LinkedList<int[]> que=newLinkedList<>();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp