File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 133
133
| 389| [ 找不同] ( https://leetcode.cn/problems/find-the-difference/ ) | [ JavaScript] ( ./algorithms/find-the-difference.js ) | Easy|
134
134
| 396| [ 旋转函数] ( https://leetcode.cn/problems/rotate-function/ ) | [ JavaScript] ( ./algorithms/rotate-function.js ) | Medium|
135
135
| 404| [ 左叶子之和] ( https://leetcode.cn/problems/sum-of-left-leaves/ ) | [ JavaScript] ( ./algorithms/sum-of-left-leaves.js ) | Easy|
136
+ | 406| [ 根据身高重建队列] ( https://leetcode.cn/problems/queue-reconstruction-by-height/ ) | [ JavaScript] ( ./algorithms/queue-reconstruction-by-height.js ) | Medium|
136
137
| 412| [ Fizz Buzz] ( https://leetcode.cn/problems/fizz-buzz/ ) | [ JavaScript] ( ./algorithms/fizz-buzz.js ) | Easy|
137
138
| 414| [ 第三大的数] ( https://leetcode.cn/problems/third-maximum-number/ ) | [ JavaScript] ( ./algorithms/third-maximum-number.js ) | Easy|
138
139
| 442| [ 数组中重复的数据] ( https://leetcode.cn/problems/find-all-duplicates-in-an-array/ ) | [ JavaScript] ( ./algorithms/find-all-duplicates-in-an-array.js ) | Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 406. 根据身高重建队列
3
+ * @param {number[][] } people
4
+ * @return {number[][] }
5
+ */
6
+ var reconstructQueue = function ( people ) {
7
+ // 按照身高从高到低排序
8
+ people . sort ( ( a , b ) => {
9
+ if ( a [ 0 ] === b [ 0 ] ) {
10
+ return a [ 1 ] - b [ 1 ] ;
11
+ }
12
+ return b [ 0 ] - a [ 0 ] ;
13
+ } ) ;
14
+
15
+ const result = [ ] ;
16
+ for ( let i = 0 ; i < people . length ; i ++ ) {
17
+ // 依次插队
18
+ result . splice ( people [ i ] [ 1 ] , 0 , people [ i ] ) ;
19
+ }
20
+
21
+ return result ;
22
+ } ;
You can’t perform that action at this time.
0 commit comments