class Solution:
def wiggleMaxLength(self, nums: List[int]) -> int:
if len(nums) == 1 or nums.count(0) == len(nums):
return 1
answer = 2
between = []
for i in range(1, len(nums)):
# The value is not zero
diff = nums[i] - nums[i - 1]
if diff > 0:
between.append(True)
if diff < 0:
between.append(False)
for i in range(1, len(between)):
if between[i] != between[i - 1]:
answer += 1
return answer