Count visible people in a line

0
Remix

People stand in a line and heights[i] is the height of the person at position i. Two people can see each other when nobody standing between them is taller than both of them.

First return how many people the last person in the line can see. Then return that count for every position.

GoogleTechnical phone screenLast asked Jul 2026
No answer yet. Write the first one; the best answer gets endorsed.