Python 3   ||   2 lines,  Counter  ||   T/S: 99% / 33%
AnotherCounterversion for consideration. Two observations:\n- ThemaxSizeparameter is a "red herring." I suspect it was added to make this problem a Medium rathe
Another`Counter`version for consideration. Two observations:\n- The`maxSize`parameter is a "red herring." I suspect it was added to make this problem a *Medium* rather than an *Easy*. For example, if the string`"abcdef"`has five occurrences, then so does`"abc"` Thus, if `minSize = 3`, then we only need check strings of length three.\n- There are some test cases in which no substring qualifies under the`maxLetters`constraint, so using the`default`parameter in`max`takes care of that.\n```\nclass Solution:\n    def maxFreq(self, s: str, maxLetters: int, minSize: int, maxSize: int) -> int:\n\n        c = Counter([s[i:i+minSize] for i in range(len(s)-minSize+1)])\n      \n        return max((c[substr] for substr in c\n                      if len(set(substr)) <= maxLetters), default = 0)\n```\nhttps://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/submissions/1276785539/\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*), in which *N* ~ `len(s)`.\n
['Python3']