← 返回 meta 的题目列表Buildings with Ocean View
类型:online_judge
Given an integer array representing the heights of the apartments, where the leftmost apartment is at index 0 and the rightmost side faces the ocean. Return the indexes of apartments that have an ocean view.
Input: An integer array apartments representing the heights of the apartments from left to right. Output: A list of indexes of the apartments that have an ocean view.
Example:
Input: [4, 3, 2, 3, 1]
Output: [0, 3, 4]
Requirement: Implement a function have_ocean_view(apartments: list[int]) -> list[int] that solves this problem and specify its time complexity.
Example
Input
[4, 3, 2, 3, 1]