Sliding Window - O(n)
Approach\n1) Move the window from 0->n, with incrementing the character count in map/dict\n2) When count of each chars in dict is set [could be =1 or >1], we ha
# Approach\n1) Move the window from 0->n, with incrementing the character count in map/dict\n2) When count of each chars in dict is set [could be =1 or >1], we have a valid substring\n3) From valid substring\'s end [window end /right pointer], count how many other substrings are possible and add it to result\n\nDry Run of 1 case:\nGiven s=\'abcabc\'\n\nAt index=2, dict={a:1,b:1,c:1}\nright pointer = 2\nlength of s = 6 \n\nTotal substrings possible from index 3 to end?\nlength of s - right => 6-2 = 4\n\nWhich 4 substirngs?\n\'abc\' [the one we got when dict is set]\n\n[Remaining substring\'s]\n\'abc\'a\n\'abc\'ab\n\'abc\'abc\n\n\n\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(3) ->\n\n# Code\n```\nclass Solution:\n    def numberOfSubstrings(self, s: str) -> int:\n        dict_cnt={\'a\':0,\'b\':0,\'c\':0}\n        n=len(s)\n        left=0\n        res=0\n\n        for right in range(len(s)):\n            dict_cnt[s[right]]+=1\n            while(dict_cnt[\'a\'] and dict_cnt[\'b\']  and dict_cnt[\'c\']):\n                res+=n-right\n                dict_cnt[s[left]]-=1\n                left+=1\n\n        return res\n        \n```
['Sliding Window', 'Python3']