Trains the technique from
LeetCode 3285Find Indices of Stable MountainsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Peak heights along a ridge are given as height, and a cut-off is given as threshold.
A peak is sheltered when the peak directly before it on the ridge stands strictly higher than the cut-off. The first peak has nothing before it, so it is never sheltered.
Return the positions of the sheltered peaks, in increasing order.
Example 1
Position 1 sits behind the peak of 9, which clears 7. Position 2 sits behind the peak of 3, which does not. Position 3 sits behind 14 and position 4 behind 6, so only the first of those counts.
Example 2
Every peak matches the cut-off without clearing it, so nothing is sheltered.
Example 3
Every peak clears the cut-off, so every position from 1 onwards is sheltered.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def stable_mountains(height: list[int], threshold: int) -> list[int]:public List<Integer> stableMountains(int[] height, int threshold)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.