Visible People in Line
Asked at Google
Reported by the problem's creator, not verified
Line(heights) holds people standing in a line, front to back, where heights[i] is the height of person i. Person i and person j can see each other when every person standing between them is at most as tall as the taller of the two; neighbors can always see each other.
Examples
Example 1
Input: init =
[[1,10,6,7,9,8,2,4,3,5]], operations =[["last_sees",[]]]Output:
[6]Explanation: The last person, height 5, sees the people of heights 3, 4, 2, 8, 9 and 10. The 7 and the 6 are blocked by the 9 standing between them and the end of the line, and the 1 is blocked by the 10.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.