Intuitive Optimised Brute Force
Intuition\n- Optimised Brute Force.\n\n# Approach\n- Started generating substring from index 0.\n- Stopped generating substring oncce any char freq = k\n- Added
# Intuition\n- Optimised Brute Force.\n\n# Approach\n- Started generating substring from index 0.\n- Stopped generating substring oncce any char freq = k\n- Added remaing length of substring from that char to final result\n\n# Complexity\n- Time complexity:O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int numberOfSubstrings(String s, int k) {\n       int[] freq = new int[26];\n       Arrays.fill(freq,0);\n       \n       int result = 0;\n       for(int i=0;i<s.length();i++) {\n            Arrays.fill(freq,0);\n            for(int j=i; j<s.length(); j++){\n                freq[s.charAt(j)-\'a\']++;\n                if(freq[s.charAt(j)-\'a\']>=k){\n                    result += s.length()-j;\n                    break;\n                }\n            }            \n       }\n        \n       return result;\n    }\n}\n```
['Java']