Copied solution
\n# Code\njava []\nclass Solution {\n    public int numberOfSubstrings(String s, int k) {\n        int n = s.length(), res = n*(n+1)/2;\n        int[] count = n
\n# Code\n```java []\nclass Solution {\n    public int numberOfSubstrings(String s, int k) {\n        int n = s.length(), res = n*(n+1)/2;\n        int[] count = new int[26];\n\n        for(int i=0, j=0; j<n; j++){\n            char c = s.charAt(j);\n            count[c-\'a\']++;\n\n            while(count[c-\'a\']>=k){\n                char lc = s.charAt(i);\n                count[lc-\'a\']--;\n                i++;\n            }\n            res-= (j-i+1);\n        }\n\n        return res;\n    }\n}\n```
['Java']