Easy Python Solution
Code
# Code\n```python3 []\nclass Solution:\n    def countAlternatingSubarrays(self, nums: List[int]) -> int:\n        left = right = 0\n        answer = 0\n\n        while right < len(nums):\n            answer += right - left + 1\n            right += 1\n\n            if right < len(nums) and nums[right] == nums[right - 1]:\n                left = right\n        \n        return answer\n```
['Python3']