mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 11:34:46 +08:00
0406.根据身高体重重建队列 Javascript
This commit is contained in:
@ -226,7 +226,25 @@ class Solution:
|
||||
|
||||
Go:
|
||||
|
||||
Javascript:
|
||||
```Javascript
|
||||
var reconstructQueue = function(people) {
|
||||
let queue = []
|
||||
people.sort((a, b ) => {
|
||||
if(b[0] !== a[0]) {
|
||||
return b[0] - a[0]
|
||||
} else {
|
||||
return a[1] - b[1]
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
for(let i = 0; i < people.length; i++) {
|
||||
queue.splice(people[i][1], 0, people[i])
|
||||
}
|
||||
return queue
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
-----------------------
|
||||
|
Reference in New Issue
Block a user