2762. Continuous Subarrays
## 思路
sliding window
用counter記錄window裡面的值跟個數
## Code
```python
class Solution:
def continuousSubarrays(self, nums: List[int]) -> int:
counter = defaultdict(int)
res = left = 0
for right, num in enumerate(nums):
counter[num] += 1
while max(counter) - min(counter) > 2:
if counter[nums[left]] == 1:
del counter[nums[left]]
else:
counter[nums[left]] -= 1
left += 1
res += right - left + 1
return res
```