Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 943 Bytes

_1762. Buildings With an Ocean View.md

File metadata and controls

38 lines (27 loc) · 943 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 10, 2024

Last updated : July 01, 2024


Related Topics : Array, Stack, Monotonic Stack

Acceptance Rate : 80.36 %


Solutions

Python

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)