Simple and Easy JAVA Solution , Beats 100% using Sliding Window approach
Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
# Intuition\n![Screenshot 2024-10-26 at 1.20.48\u202FAM.png](https://assets.leetcode.com/users/images/41294b0b-c98b-433a-9aa4-752eca5a73a5_1729885998.8568277.png)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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 map[] = new int[26];\n        int left = 0;\n        int right = 0;\n        int n = s.length();\n        int count = 0;\n        int ans = 0;\n        \n        while(right < n){\n            int rtCh = s.charAt(right) - \'a\';\n            if(++map[rtCh] >= k)\n                count++;\n            \n            while(left <= right && count == 1){\n                ans += n - right;\n                int lftCh = s.charAt(left) - \'a\';\n                if(map[lftCh]-- >= k)\n                    count--;\n                left++;\n            }\n\n            right++;\n        }\n\n        return ans;\n    }\n}\n```
['Sliding Window', 'Java']