people
array in descending order of height h
. For people of the same height, sort them in ascending order of k
values.queue
.people
array.(h, k)
in people
, insert them into the queue
at the index k
. This is possible because the people already in the queue
are as tall or taller than the current person.queue
after all people have been placed.