C++ || Sliding Window || Detailed Explanation
Approach\n One major thing to understand here is we only have to look out for substring with minSize satisfying the condition. Because we are concerned about fr
# Approach\n* One major thing to understand here is we only have to look out for substring with minSize satisfying the condition. Because we are concerned about frequency of occurance, and any substring S1 with size greater than minSize will have frequency less than or equal to substring of S1 with size minSize.\n* Lets say substring S1 satisfies our condition and size of substring S1 > minSize then there also exist a substring of S1 of size minSize which will satisfy our condition and will have frequency of occurance greater than S1 in the original string. \n\n* Now we will construct substring with size minSize using sliding window technique. We will store the frequency of each element in the window and check if it satisfies our condition.\n* And we will also store the frequency of each substring made with satisfied condition. \n* Return the largest frequency. \n\n```\nclass Solution {\npublic:\n    int maxFreq(string s, int maxLetters, int minSize, int maxSize) {\n        \n        int i, j, k, ans = 0, res, n = s.length();\n        \n        string temp;\n        unordered_map<char, int> st;\n        unordered_map<string, int> mp;\n        \n        i = 0, j = 0;\n        while(i <= n - minSize && j < n)\n        {\n            temp += s[j];\n            st[s[j]] += 1;;\n            if(temp.length() == minSize)\n            {\n                if(st.size() <= maxLetters)\n                    mp[temp] += 1;\n                i += 1;\n                st[temp[0]] -= 1;\n                if(st[temp[0]] == 0)\n                    st.erase(temp[0]);\n                temp.erase(temp.begin());\n            }\n            j += 1;\n        }\n        for(auto el : mp)\n            ans = max(ans, el.second);\n        return ans;\n    }\n};\n```\n\n***Please upvote if you liked the explanation.***
['C', 'Sliding Window', 'C++']