1909. Buildings With an Ocean View

Medium
Array
Stack
Monotonic Stack

Description

Hints

Hint 1
You can traverse the buildings from the nearest to the ocean to the furthest.
Hint 2
Keep with you the maximum to the right while traversing to determine if you can see the ocean or not.

Statistics

Acceptance
80.9%
Submissions
416,739
Accepted
337,063