Java beats 100%
\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n# Code\njava []\nclass Solution {\n    public int numberOfSubstrings(String s, int k) {\n        int l = 0, r = 
\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n# Code\n```java []\nclass Solution {\n    public int numberOfSubstrings(String s, int k) {\n        int l = 0, r = 0, len = s.length(), res = 0;\n        int freq[] = new int[26];\n        while(r != len && l != len) {\n            freq[s.charAt(r) - \'a\']++;\n            while(freq[s.charAt(r) - \'a\'] == k && l != len) {\n                res += len - r;\n                freq[s.charAt(l++) - \'a\']--;\n            }\n            r++;\n        }\n        return res;\n    }\n}\n```
['Java']