C++ | Easy Concise | Sliding Window
\n\n\tclass Solution {\n\tpublic:\n\t\tint numberOfSubstrings(string s) {\n\t\t\tint n = s.size(), ans = 0;\n\t\t\tmap mp;\n\t\t\tint left = 0, right = 0;\n\t\t
\n\n\tclass Solution {\n\tpublic:\n\t\tint numberOfSubstrings(string s) {\n\t\t\tint n = s.size(), ans = 0;\n\t\t\tmap<char,int> mp;\n\t\t\tint left = 0, right = 0;\n\t\t\twhile(left<n && right<n){\n\t\t\t\tmp[s[right]]++;\n\t\t\t\twhile(mp.size()==3){\n\t\t\t\t\tans+=(n-right);\n\t\t\t\t\tif(mp[s[left]]>1){\n\t\t\t\t\t\tmp[s[left]]--;\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tmp.erase(s[left]);\n\t\t\t\t\t}\n\t\t\t\t\tleft++;\n\t\t\t\t}\n\t\t\t\tright++;\n\t\t\t} \n\t\t\treturn ans;\n\t\t}\n\t};
['C', 'Sliding Window', 'C++']