#C4019. Count Important Landmarks
Count Important Landmarks
Count Important Landmarks
You are given several test cases. In each test case, you are provided with a sequence of building heights. A building is considered an important landmark if its height is strictly greater than the heights of its adjacent buildings. Formally, for a building at index \(i\) (using 0-indexing), it is an important landmark if
[ h_i > h_{i-1} \quad \text{and} \quad h_i > h_{i+1} ]
for \(1 \leq i \leq N-2\). If the number of buildings \(N\) is less than 3, then there are no adjacent pairs to compare and the answer should be 0
.
Your task is to count the number of important landmarks in each test case.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\) representing the number of test cases.
- Then for each test case:
- The first line contains an integer \(N\), the number of buildings.
- The next line contains \(N\) space-separated integers representing the heights of the buildings.
outputFormat
For each test case, output a single line containing the number of important landmarks.
## sample2
5
3 1 4 1 5
6
1 2 3 4 3 2
1
1
</p>