Approach Summary
Sort by height descending (ties: k ascending). Insert each person at index k. Taller people already placed, so k is still valid.
How to Recognize This Pattern
- Place tallest first — they don't affect taller-count for shorter people
- Greedy insertion at k-th position
Complexity Analysis
Time Complexity
O(n²)
Space Complexity
O(n)
Tags
Array Greedy Sorting