You are given an array of people,
people, which are the attributes of some people in a queue (not necessarily in order). Each
people[i] = [hi, ki] represents the
ith person of height
hi with exactly
ki other people in front who have a height greater than or equal to
Reconstruct and return the queue that is represented by the input array
people. The returned queue should be formatted as an array
queue[j] = [hj, kj] is the attributes of the
jth person in the queue (
queue is the person at the front of the queue).
Input: people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]
Because the larger the number, the less of the number larger than him, and the smaller the number, the more of numbers larger than him. Therefore, I sort by people[i], from larger to smaller. If there are the same numbers, I accord to number of people[i] and sort from smaller to larger.
Then, I need to reorder the array and it is according to people[i].