#K36692. Visible Hills
Visible Hills
Visible Hills
You are given an array of non-negative integers representing the heights of a sequence of hills. A hill is considered visible if and only if its height is strictly greater than every hill to its left. Formally, a hill at index \(i\) is visible if
\[ height[i] > \max_{0 \le j < i} height[j] \]
Your task is to determine and print the indices (0-indexed) of all hills that are visible when observed from the left.
Note: If the array is empty, output an empty line.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains a single integer \(n\) representing the number of hills.
- The second line contains \(n\) space-separated integers representing the heights of the hills.
outputFormat
Print a single line to standard output (stdout) containing the indices of the visible hills in ascending order, separated by a single space. If no hill is visible (i.e. when \(n=0\)), print an empty line.
## sample8
1 3 2 4 1 5 3 2
0 1 3 5
</p>