```
class Solution(object):
def wiggleMaxLength(self, nums):
if not nums:
return 0
seq = [0] + [nums[i+1]-nums[i] for i in range(len(nums)-1)]
count = 1
for i in range(1,len(seq)):
if (seq[i] > 0 and seq[i-1] <= 0) or (seq[i] < 0 and seq[i-1] >= 0):
count += 1
elif seq[i] == 0:
seq[i] = seq[i-1]
return count
```