You have a queue of people with attributes where is height and is the number of people in front who are taller or equal height. Reconstruct the queue.
For example, becomes . The order you insert people matters.
Think about which people are easiest to place correctly. Greedy insight: tallest people have the simplest constraints because no one shorter affects them.