#K836. Count Peaks in an Array
Count Peaks in an Array
Count Peaks in an Array
You are given an array of N integers. Your task is to count the number of peaks in the array. An element at index i (1 ≤ i ≤ N-2) is considered a peak if it is strictly greater than both of its immediate neighbors, i.e. it satisfies:
\( arr[i] > arr[i-1] \quad \text{and} \quad arr[i] > arr[i+1] \)
Note that the first and last elements of the array are not considered, as they have only one neighbor each.
For example, in the array [1, 3, 2, 4, 1, 5], there are 2 peaks: 3 and 4.
inputFormat
The first line of input contains an integer N, the number of elements in the array.
The second line contains N space-separated integers representing the array elements.
outputFormat
Output a single integer - the number of peaks found in the array.
## sample6
1 3 2 4 1 5
2
</p>