Greedy Algorithms - Wiggle Subsequence
Examine the following Python code snippet for the wiggle subsequence problem. Which line contains a subtle bug that causes incorrect results when the input has consecutive equal elements?
```python
def wiggleMaxLength(nums):
if not nums:
return 0
count = 1
last_diff = 0
for i in range(1, len(nums)):
diff = nums[i] - nums[i-1]
if (diff > 0 and last_diff <= 0):
count += 1
last_diff = diff
elif (diff < 0 and last_diff >= 0):
count += 1
last_diff = diff
return count
```
