Tap here to switch tabs
Problem
Submissions

Problem: Buildings With an Ocean View

Try to solve the Buildings With an Ocean View problem.

Statement

You are given an integer array heights representing the heights of buildings in a row. The ocean is located to the right of all the buildings.

A building has an ocean view if every building to its right has a strictly smaller height.

Return an array containing the indices of all buildings that have an ocean view, sorted in increasing order. The indices are 00 indexed.

Constraints:

  • 1≤1 \leq heights.length ≤105\leq 10^5

  • 1≤1 \leq heights[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Buildings With an Ocean View

Try to solve the Buildings With an Ocean View problem.

Statement

You are given an integer array heights representing the heights of buildings in a row. The ocean is located to the right of all the buildings.

A building has an ocean view if every building to its right has a strictly smaller height.

Return an array containing the indices of all buildings that have an ocean view, sorted in increasing order. The indices are 00 indexed.

Constraints:

  • 1≤1 \leq heights.length ≤105\leq 10^5

  • 1≤1 \leq heights[i] ≤109\leq 10^9