#C5641. Wave Array
Wave Array
Wave Array
Given an array of integers arranged in a sequence, determine whether the array forms a wave pattern. An array is considered to be a wave if for every three consecutive elements, the difference between the first two elements and the difference between the last two elements have opposite signs, i.e., their product is negative. In mathematical terms, for an array (a_0, a_1, \ldots, a_{n-1}) with (n \ge 3), the array is a wave if for every (i) such that (1 \le i \le n-2), [ (a_i - a_{i-1}) \times (a_{i+1} - a_i) < 0 ] Additionally, any array with fewer than 2 elements is considered to be a wave. Your task is to implement an algorithm to check for this wave pattern.
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 elements of the array.
outputFormat
Output a single line containing either 'True' or 'False'. Output 'True' if the array forms a wave, otherwise output 'False'.## sample
5
1 3 2 4 3
True