C++ || Easy approach
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(n)\n\n- Space complexity:O(3)\n\n# Code\n\nclass Solution {\npublic:\n    int numberO
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(n)\n\n- Space complexity:O(3)\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfSubstrings(string s) {\n        int cnt=0, j=0;\n        vector<int>v(3, 0);\n        for(int i=0; i<s.size(); i++){\n            v[s[i]-\'a\']++;\n            while(v[0] && v[1] && v[2]){\n                cnt+=s.size()-i;\n                v[s[j]-\'a\']--;\n                j++;\n            }\n        }\n        return cnt;\n    }\n};\n```
['C++']