Video Explanation Solution easy to understand | Programming with Pirai | Half Moon Coder.
Video : Code
# Video : https://youtu.be/3Kb-DYfwinY

# Code
```python3 []
class Solution:
    def countAlternatingSubarrays(self, nums: List[int]) -> int:
        res=c=1
        for i in range(1,len(nums)):
            if nums[i]!=nums[i-1]:
                c+=1  
            else:
                c=1
            res+=c
        return res
```
['Array', 'Math', 'Python3']