C++ solution using sliding window way
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    int numberOfSubstrings(string s, int k) {\n\n        int res = 0;\n        int count_larger_k = 0;\n        u
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int numberOfSubstrings(string s, int k) {\n\n        int res = 0;\n        int count_larger_k = 0;\n        unordered_map<char, int> char2Int;\n        int i = 0;\n        \n\n        for(int j = 0; j < s.size();j ++) {\n            char cur_char = s[j];\n            char2Int[cur_char] += 1;\n            if(char2Int[cur_char] == k) {\n                count_larger_k += 1;\n            }\n\n            while(count_larger_k != 0) {\n                res += s.size() - j;\n\n                char2Int[s[i]] -= 1;\n                if(char2Int[s[i]] == k-1) {\n                    count_larger_k -= 1;\n                }\n                i++;\n                \n            }\n        }\n\n        return res;\n        \n    }\n};\n```
['C++']