C++||Sliding Window || O(n) || Aditya-verma way
Steps:\n1. Take a hasmap and store iterate the j pointer till the size of the map doesn\'t becomes 3.\n2. After the size becomes equal to 3 increament the count
**Steps:**\n1. Take a hasmap and store iterate the j pointer till the size of the map doesn\'t becomes 3.\n2. After the size becomes equal to 3 increament the count by (n-j) because the at the index j at which the size of map becomes 3 the next j index will also satisfy the given condition .\n3. Increament the i pointer now and decrease the calculation done for i th index.\n\n```\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        int i=0,j=0;\n        int n = s.size();\n        map<char,int> mp;\n        int count=0;\n        while(j<n){\n            mp[s[j]]++;\n            if(mp.size()<3){\n                j++;\n            }\n            else{\n               while(mp.size()==3){\n                   count+=(n-j);\n                   mp[s[i]]--;\n                   if(mp[s[i]]==0) mp.erase(s[i]);\n                   i++;\n                }\n                j++;\n            }\n        }\n        return count;\n    }\n};\n```\n**TC-O(n)\nSC-O(1)**\n*KINDLY UPVOTE*
['C', 'Sliding Window']