Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers(h, k), wherehis the height of the person andkis the number of people in front of this person who have a height greater than or equal toh. Write an algorithm to reconstruct the queue.
Note:
The number of people is less than 1,100.
Example
Input: ?[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]
Output: ?[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]]
h 為身高, k為排在他前面的身高大于等于他身高的人數。
step1: 身高降序排列, 如果身高一致,很顯然k要升序排列。
list to array 時候要在參數里new 一個int的數組! 這個輸入參數的格式作為模板傳進去, 等返回來時,已經裝滿了數據。 想想滿滿的幸福感。?