Free written solutionCount Hills and Valleys in an Array (LeetCode 2210): Solution and Explanation
Count the peaks and dips in an array, where a run of equal values counts as a single peak or dip and both ends of the array never count.
Read the intuition, approach, code and complexity →