C++ Writeup of how i understood it
\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        /*\n            0 1 2 3 4 5 6 7 8\n            a a b c c c b a c\n            logic
```\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        /*\n            0 1 2 3 4 5 6 7 8\n            a a b c c c b a c\n            logic here is: go till min string with all characters, eg:\n            s = abcabc\n            abc is min string with all chracters, now whatever character we have after c\n            will be valid as we atleast got abc once, so combination for this set of abc will be\n            abc\n            abca\n            abcab\n            abcabc\n            here we can observe that till min string index, it become one of the combination and \n            rest combinations come from n-j.\n            -> now with this, there can be more than one min string with abc in middle too which will give\n            their individual combinations, so for that we \n            while condition which keeps track of all min string with atleast one time abc in it.\n        */\n        unordered_map<char,int> alpha;\n        int i=0,j=0,ans=0,n=s.size();\n        while(j<n){\n            alpha[s[j]]++; //getting min string with abc characters\n            while(alpha[\'a\']>0 && alpha[\'b\']>0 && alpha[\'c\']>0){\n                ans+=(n-j); // it gives all combination per completed(in which all three characters are present) string.\n                alpha[s[i]]--; //considering possiblities of substring by remove earlier seen characters\n                //and adding new characters(minimising window)\n\t\t\t\t/*\n\t\t\t\t\tnow here, why we are doing it consider example of string: aabcccabc\n\t\t\t\t\tour first min string will be aabc and it\'s combination which is n-j,\n\t\t\t\t\tnow this operation is done to get combination of other set of string, i.e; abc(1,2,3 index)\n\t\t\t\t\tso now all combination of this string will be added, likewise we are going to make window\n\t\t\t\t\tsmall to get their combinations.\n\t\t\t\t*/\n                i++;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['C']