Skip to main content

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.

Back to lesson: Practice: Array lab