Ocean View Buildings
Imagine a row of buildings by the shore: the ocean is on the right, and a taller building can block the view for buildings to its left. Given a list of building heights heights, return the indices of buildings that can see the ocean. A building has an ocean view if there is no building of the same height or greater to its right.
Примеры
Ввод
[4, 2, 3, 1]Вывод
[0, 2, 3]Ввод
[4, 3, 2, 1]Вывод
[0, 1, 2, 3]Ввод
[1, 3, 2, 4]Вывод
[3]Нужно реализовать
def find_buildings(heights: list[int]) -> list[int]:
Теги
arraystack
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
[4,2,3,1]Expected
[0,2,3]2
Input
[4,3,2,1]Expected
[0,1,2,3]3
Input
[1,3,2,4]Expected
[3]4
Input
[2,2,2,2]Expected
[3]5
Input
[1]Expected
[0]6
Input
[]Expected
[]Focus radio
Paused · SomaFM · Fluid