Trains the technique from
LeetCode 2951Find the PeaksThis 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.
A survey profile is given as mountain, where mountain[i] is the height at station i.
A station is a ridge point when it is strictly higher than the station on each side of it. The first and last stations are never ridge points, since each has only one neighbour.
Return the ridge point stations in increasing order.
Example 1
Station 1 stands at 5 above the 2 and the 3 beside it, and station 3 stands at 6 above the 3 and the 4 beside it.
Example 2
Stations 1 and 2 are both at height 3, so neither stands strictly above both of its neighbours.
Example 3
The only station with a neighbour on each side is station 1, and it stands below station 2.
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 ridge_points(mountain: list[int]) -> list[int]:public List<Integer> ridgePoints(int[] mountain)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.