All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 10, 2024
Last updated : July 01, 2024
Related Topics : Array, Stack, Monotonic Stack
Acceptance Rate : 80.36 %
class Solution:
def findBuildings(self, heights: List[int]) -> List[int]:
output = []
currentMax = -inf
for i in range(len(heights) - 1, -1, -1) :
if heights[i] > currentMax :
output.append(i)
currentMax = heights[i]
return reversed(output)