C++ || Map and Sliding Window || Easy and Simple || 30ms, 8.5 MB
\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        int i=0,j=0,tt=0,n=s.size(),ans{};\n        vector<int> m(3,0);\n        while(i<n)
```\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        int i=0,j=0,tt=0,n=s.size(),ans{};\n        vector<int> m(3,0);\n        while(i<n)\n        {\n            m[s[i]-\'a\']++; //add the latest element to window\n            while(m[0]>0 and m[1]>0 and m[2]>0)\n            {\n                m[s[j]-\'a\']--; //remove the 1st element of window\n                j++; //slide the window\n                ans+=n-i; // add n-(window length) to answer\n            }\n            i++;\n        }\n        return ans;\n    }\n};\n```
['C', 'Sliding Window']