Leetcode 406. Queue Reconstruction by Height
Given pairs (h, k) where k is the number of people with height >= h standing in front of that person, reconstruct the queue ordering that satisfies all constraints. This is a greedy/reconstruction problem typically solved by processing taller people first and inserting each person at position k to preserve the counts.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early August, 2026
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 hi. Reconstruct and return the queue that is represented by the input array people. The returned queue should be formatted as an array queue, where queue[j] = [hj, kj] is the attributes of the jth person in the queue (queue[0] is the person at the front of the queue).
Hello Interview Premium
Your account is free and you can post anonymously if you choose.