Sort and insert
Time O(n²) for list insertions Space O(n)After sorting, inserting [h, k] at position k is correct: everyone already placed is at least as tall.
import java.util.*;
class Solution {
public int[][] reconstructQueue(int[][] people) {
Arrays.sort(people, (a, b) -> a[0] != b[0] ? Integer.compare(b[0], a[0]) : Integer.compare(a[1], b[1]));
List<int[]> queue = new ArrayList<>();
for (int[] p : people) queue.add(p[1], p);
return queue.toArray(new int[0][]);
}
}Verdict: Simple; n ≤ 2000.