406. Queue Reconstruction by Height 依高度重建隊列
❀ Origin
Problem
Suppose you have a random list of people standing in a queue.
Each person is described by a pair of integers (h, k)
,
where h
is the height of the person and k
is the number of people in front of this person who have a height greater than or equal to h
. Write an algorithm to reconstruct the queue.
Note
- The number of people is less than
1,100
.
Example
1 | Input: |
❀ 翻譯
問題
假設有一個隨機的人們排隊的列表.
每個人都用一對整數 (h, k)
來描述,h
代表著那人的身高, 而 k
則是身高高於或等於 h
的人在他前面的數量.
寫出一個算法來重建這個隊列.
注意
- 人數小於
1,100
❀ Solution
JavaScript
1 | /** |