towers from left to right. The sea lies to the right of the last tower.
A tower can see the sea if every tower to its right is strictly shorter. Return the 0-based indices of all towers with a sea view, in increasing order.towers=[5, 2, 4, 4, 1] → [0, 3, 4]
Tower 2 is blocked by tower 3 of the same height, tower 1 by the taller ones to its right. Towers 0, 3 and 4 see the sea.
towers=[2, 3, 7] → [2]
The rightmost tower is also the tallest and blocks everyone else.
towers=[9, 6, 3] → [0, 1, 2]
towers=[5, 2, 4, 4, 1]
[0, 3, 4]
Run checks the first 3 tests in your browser. Submit checks all 131 tests on the server, hidden ones included.