Dynamic Programming🔥🔥 || Python
\n\n# Code\n\nclass Solution:\n    def countAlternatingSubarrays(self, nums: List[int]) -> int:\n        #dp=[1]*len(nums)\n        s=1\n        curr=1\n       
\n\n# Code\n```\nclass Solution:\n    def countAlternatingSubarrays(self, nums: List[int]) -> int:\n        #dp=[1]*len(nums)\n        s=1\n        curr=1\n        for i in range(1,len(nums)):\n            if nums[i]!=nums[i-1]:\n                curr=curr+1\n                s+=curr\n            else:\n                curr=1\n                s+=curr\n                \n        return s\n        \n```
['Dynamic Programming', 'Python3']