You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* For every position in the array, there are only three possible statuses for it.
10
+
* <p>
11
+
* up position, it means nums[i] > nums[i-1]
12
+
* down position, it means nums[i] < nums[i-1]
13
+
* equals to position, nums[i] == nums[i-1]
14
+
* So we can use two arrays up[] and down[] to record the max wiggle sequence length so far at index i.
15
+
* If nums[i] > nums[i-1], that means it wiggles up. the element before it must be a down position. so up[i] = down[i-1] + 1; down[i] keeps the same with before.
16
+
* If nums[i] < nums[i-1], that means it wiggles down. the element before it must be a up position. so down[i] = up[i-1] + 1; up[i] keeps the same with before.
17
+
* If nums[i] == nums[i-1], that means it will not change anything becasue it didn't wiggle at all. so both down[i] and up[i] keep the same.
0 commit comments