Python easy to understand - IMPORTANT intuition
Based on @lee215 solution:\n\nMain thing here is to understand the intuition behind way we need not care about maxSize. \nHere the goal is to count max number o
Based on @lee215 solution:\n\nMain thing here is to understand the intuition behind way we need not care about maxSize. \nHere the goal is to count max number of substrings with atleast minSize. We only care about the count and not the substring itself! \n\nIf number of (S1) substrings with size = maxSize is 4, then there will be substrings(s2) which is part of S1 with count equal or greater than 4 for sure.\n\n```\nclass Solution:\n    def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int:\n        \'\'\'\n        Intuition\n        If a string have occurrences x times,\n        any of its substring must appear at least x times.\n\n        There must be a substring of length minSize, that has the most occurrences.\n        So that we just need to count the occurrences of all substring with length minSize.\n        \n        \'\'\'\n        \n        w_lookup = defaultdict(int)\n        \n        for i in range(minSize, len(s)+1):\n            w = s[i-minSize:i]\n            \n            if len(set(w)) <= maxLetters:\n                w_lookup[w] += 1\n        \n        if w_lookup:\n            return max(w_lookup.values())\n        else:\n            return 0\n```
[]