406. Queue Reconstruction by Height

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的数组! 这个输入参数的格式作为模板传进去, 等返回来时,已经装满了数据。 想想满满的幸福感。 

406. Queue Reconstruction by Height_第1张图片

你可能感兴趣的:(406. Queue Reconstruction by Height)