Skip to content

Commit 724be38

Browse files
authoredJun 6, 2020
Update 406-queue-reconstruction-by-height.js
1 parent 8c4e879 commit 724be38

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎406-queue-reconstruction-by-height.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* @param {number[][]} people
3+
* @return {number[][]}
4+
*/
5+
const reconstructQueue = function (people) {
6+
const h = 0
7+
const k = 1
8+
people.sort((a, b) => (a[h] == b[h] ? a[k] - b[k] : b[h] - a[h]))
9+
let queue = []
10+
for (let person of people) {
11+
queue.splice(person[k], 0, person)
12+
}
13+
return queue
14+
}
15+
16+
// another
17+
118
/**
219
* @param {number[][]} people
320
* @return {number[][]}

0 commit comments

Comments
 (0)
Please sign in to comment.