Hints — p81 Queue Reconstruction by Height

  1. The k field counts taller-or-equal in front, not strictly taller. Same-height people count.

  2. If you place the tallest person first, no one you place later can ever invalidate their k-count (shorter people don’t add to “taller-or-equal”).

  3. Sort by (-h, k) — tallest first, then ascending k among ties. Process in this order.

  4. When inserting person (h, k): every already-placed person has height ≥ h. So the insertion index = count of taller-or-equal in front = k. Use list.insert(k, [h, k]).

  5. Ascending k for ties matters: same-height persons count toward each other’s k, so place the one with smaller k first.

If stuck: see solution.py.