A wiggle sequence is one where the differences between consecutive numbers strictly alternate between positive and negative. The first difference may be either positive or negative. A sequence with one element, or two unequal elements, is trivially a wiggle sequence.
For example, [1, 7, 4, 9, 2, 5] is a wiggle sequence because its differences (6, -3, 5, -7, 3) alternate in sign. [1, 4, 7, 2, 5] is not (the first two differences are both positive), and neither is [1, 7, 4, 5, 5] (the last difference is zero).
A subsequence is obtained by deleting some elements (possibly none) from the original sequence while keeping the rest in order.
Given an integer array nums, return the length of the longest wiggle subsequence of nums.