We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dc531fd + 01f14ae commit c74c8b1Copy full SHA for c74c8b1
problems/0406.根据身高重建队列.md
@@ -188,15 +188,10 @@ Java:
188
```java
189
class Solution {
190
public int[][] reconstructQueue(int[][] people) {
191
- Arrays.sort(people, new Comparator<int[]>() {
192
- @Override
193
- public int compare(int[] o1, int[] o2) {
194
- if (o1[0] != o2[0]) {
195
- return Integer.compare(o2[0],o1[0]);
196
- } else {
197
- return Integer.compare(o1[1],o2[1]);
198
- }
199
+ // 身高从大到小排(身高相同k小的站前面)
+ Arrays.sort(people, (a, b) -> {
+ if (a[0] == b[0]) return a[1] - b[1];
+ return b[0] - a[0];
200
});
201
202
LinkedList<int[]> que = new LinkedList<>();
0 commit comments