#K9291. Local Minimum Water Catching
Local Minimum Water Catching
Local Minimum Water Catching
You are given an array of integers representing the heights of hills. A hill at position (i) (with (1 \le i \le n-2)) is considered a local minimum if it satisfies the condition (h_i < h_{i-1}) and (h_i < h_{i+1}). Such a point can potentially hold water. Your task is to determine whether there exists at least one local minimum in the given array. Print True
if there is at least one local minimum, otherwise print False
.
inputFormat
The input is given via standard input (stdin). The first line contains an integer (n) ((0 \le n \le 10^5)) representing the number of hill heights. The second line contains (n) space-separated integers representing the hill heights.
outputFormat
Output a single line to standard output (stdout) containing either True
if there exists at least one local minimum that can hold water, or False
otherwise.## sample
8
1 2 1 3 4 3 1 2
True