How many people each person can see
People stand in a line, all facing right, and heights[i] is the height of person i; no two heights are equal. Person i can see person j > i when everyone standing between them is shorter than both of them. Return how many people each person can see. For [10, 6, 8, 5, 11, 9] the answer is [3, 1, 2, 1, 1, 0]: the first person sees 6, 8 and 11, but not 5 (8 is in the way) or 9 (11 is).
heights may be empty; heights are distinct positive integers. Aim for O(n): checking every pair is O(n²).
Besides the tests, one large input (7,000 people) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
visible_counts([10,6,8,5,11,9])→[3,1,2,1,1,0]visible_counts([5,1,2,3,10])→[4,1,1,1,0]visible_counts([3,2,1])→[1,1,0]