Easy to understand approach using HashMap
Intuition\n Describe your first thoughts on how to solve this problem. \nGenerate all substring and maintain a hashmap to store count of letters and for every c
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGenerate all substring and maintain a hashmap to store count of letters and for every character appearing atleast k times, increase the count.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGreedily generate all substring and do as required.\nFor every \'i\', generate a new map and while iterating across the map,count the number of times any character apprears and if the count is greater than equal to $k$, increase count by 1.\n# Complexity\n- Time complexity:- $O(n^2)$ since all substrings are being constructed.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(1)$ since the size of hashmap never exceeds 26.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int numberOfSubstrings(string s, int k) {\n        int ans=0;\n        for(int i=0;i<s.size();++i)\n        {\n            unordered_map<char,int>mp;\n            for(int j=i;j<s.size();++j)\n            {\n                ++mp[s[j]];\n                bool flag=0;\n                for(auto iter:mp)\n                {\n                    if(iter.second>=k)\n                    {\n                        //++ans;\n                        flag=1;\n                        break;\n                    }\n                }\n                if(flag==1)\n                    ++ans;\n            }\n        }\n        return ans;\n    }\n};\n```
['Hash Table', 'String', 'C++']