Python
1) This is a classic Sliding Window problem. You use two variables i.e., left and right\n2) Whenever the length of the dictionary is 3 it means you have all the
1) This is a classic Sliding Window problem. You use two variables i.e., left and right\n2) Whenever the length of the dictionary is 3 it means you have all the three characters i.e., a,b,and c. We can simply add n-right here since all the subarrays containing sub[left:right] will have the three characters. You now move the left to see if there is any subarray falling inside sub[left:right] that has all the three characters.\n\n```\nclass Solution:\n    def numberOfSubstrings(self, s: str) -> int:\n        n=len(s)\n        if n<3:\n            return 0\n        left,right,d=0,-1,{}\n        count=0\n        while(right<n):\n            if len(d)==3:\n                count+=n-right\n                d[s[left]]-=1\n                if d[s[left]]==0:\n                    del d[s[left]]\n                left+=1\n            else:\n                right+=1\n                if right>=n:\n                    break\n                else:\n                    if s[right] in d:\n                        d[s[right]]+=1\n                    else:\n                        d[s[right]]=1\n        return count\n```\n\n
['Sliding Window']