[C++] Basic approach, just remove extra calculations.
The most basic approach is to check occurences of substrings of minSize to maxSize and counting their occurences using a map. If you look closely, each occurenc
The most basic approach is to check occurences of substrings of minSize to maxSize and counting their occurences using a map. If you look closely, each occurence of a substring with length more than ```minSize``` will actually encompass a string of ```minSize``` itself, therefore we just need to check and ```count frequency of minSize substrings```.\n\n```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n\t\t// map to count frequencies.\n        unordered_map<string, int> m;\n\t\t// keep a count of max frequency found.\n        int max_freq = 0;\n        \n        for (int i = 0; i < s.size() - minSize + 1; i++) {\n            string temp = s.substr(i,minSize);\n\t\t\t// make a set and compare size to check unique\n\t\t\t// characters in substrings < maxLetters.\n            unordered_set<char> st(temp.begin(), temp.end());\n            if (st.size() <= maxLetters) {\n                m[temp]++;\n                max_freq = max(max_freq, m[temp]);\n            }\n        }\n      \n        return max_freq;\n    }\n};\n```
[]