C++ Solution Using sliding window technique
\n\t//Average Time complexity O(n), Space complexity O(1)\n\tclass Solution {\n\tpublic:\n\t\tint numberOfSubstrings(string s) {\n\n\t\t\tint a = 0, b = 0, c = 
\n\t//Average Time complexity O(n), Space complexity O(1)\n\tclass Solution {\n\tpublic:\n\t\tint numberOfSubstrings(string s) {\n\n\t\t\tint a = 0, b = 0, c = 0;\n\n\t\t\tint ans = 0;\n\t\t\tint len = s.length();\n\t\t\tint low = 0;\n\t\t\tint high= 0;\n\t\t\twhile(low < len && low <= high && high <= len) {\n\t\t\t\tif (a && b && c) {\n\t\t\t\t\tans += len - (high -1);\n\t\t\t\t\tif (s[low] == \'a\')\n\t\t\t\t\t\ta--;\n\t\t\t\t\telse if (s[low] == \'b\')\n\t\t\t\t\t\tb--;\n\t\t\t\t\telse \n\t\t\t\t\t\tc--;\n\t\t\t\t\tlow++;\n\t\t\t\t} else {\n\t\t\t\t\tif (s[high] == \'a\')\n\t\t\t\t\t\ta++;\n\t\t\t\t\telse if (s[high] == \'b\')\n\t\t\t\t\t\tb++;\n\t\t\t\t\telse \n\t\t\t\t\t\tc++;\n\t\t\t\t\thigh++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn ans;\n\t\t}\n\t};
['String', 'C', 'Sliding Window']