#K44187. Wiggle Sequence Checker
Wiggle Sequence Checker
Wiggle Sequence Checker
You are given an array of integers \(a_1, a_2, \ldots, a_n\). A sequence is called a wiggle sequence if the differences between successive numbers strictly alternate in sign. In other words, if \(d_i = a_{i+1} - a_i\) for \(1 \le i < n\), then the sequence is a wiggle sequence if for every \(i\) (with \(1 \le i \le n-2\)),
[ d_i \times d_{i+1} < 0 ]
Note that a sequence with fewer than two elements is trivially considered a wiggle sequence. Your task is to determine for each test case whether the given array is a wiggle sequence.
inputFormat
The first line of input contains an integer \(T\), representing the number of test cases. For each test case, the first line contains an integer \(N\) (the number of elements in the array), followed by a line of \(N\) space-separated integers representing the array elements.
outputFormat
For each test case, output a single line containing either True
if the array is a wiggle sequence, or False
otherwise.
1
1
1
True
</p>