Practice · 1 of 6
Count the peaks
CHALLENGE
Difficulty: intermediate+25 XP
Implement int countPeaks(int[] arr): elements strictly greater than BOTH immediate neighbors. The first and last elements are never peaks — size your loop bounds accordingly.
Press Submit to check your solution.
Back to lesson: Practice: Array lab