Easy · Stacks & Queues

Buildings With an Ocean View

Given an array heights of positive building heights in a row, with the ocean to the right of the last building, return the 0-based indices, in increasing order, of the buildings whose every building to the right is strictly shorter.

Examples

Example 1

[4,2,3,1]

Output: [0,2,3]

Example 2

[1,3,2,4]

Output: [3]

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Stacks & Queues problems