[Python] Oneliner using groupby, explained
What you need to do in this problem is just iterate over string and find groups of equal symbols, and then return the length of the longest group. Natural way t
What you need to do in this problem is just iterate over string and find groups of equal symbols, and then return the length of the longest group. Natural way to do it is to use functionality of itertools library, more precisely `groupby` function. By definition, if we do not specify arguments for groupby, it will create groups exactly with equal elements, so what we need to do is just to choose group with the biggest size and return it!\n\n**Complexity**: time and space complexity is `O(n)`, because we iterate over our data once, but also we need to have space to keep our groupby object.\n\n```\nclass Solution:\n    def maxPower(self, s):\n         return max(len(list(j)) for _, j in groupby(s))\n```\n\nIf you have any questions, feel free to ask. If you like solution and explanations, please **Upvote!**
[]