Simple Python and Java solution | Easy to understand
Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem aims to find the maximum consecutive occurrences of any character within a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem aims to find the maximum consecutive occurrences of any character within a given string. Essentially, we need to identify continuous sequences of the same character and determine the length of the longest such sequence.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize variables prev, count, and maxcount to track the previous character, count of consecutive occurrences, and the maximum count encountered so far, respectively. \n2. Iterate through the string, starting from the second character. \n3. For each character at index i, check if it matches the previous character (prev). If it does, increment the count variable to represent consecutive occurrences. If it doesn\'t match, update prev to the current character and reset count to 1. \n4. During each iteration, update maxcount to store the maximum value between the current count and the existing maxcount. \n5. Return maxcount, which represents the maximum consecutive occurrences of any character within the input string.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```Python []\nclass Solution:\n    def maxPower(self, s: str) -> int:\n        prev = s[0]\n        count = 1\n        maxcount = 1\n        for i in range(1,len(s)):\n            if s[i] == prev:\n                count += 1\n            else:\n                prev = s[i]\n                count = 1\n            maxcount = max(count,maxcount)\n        return maxcount\n```\n```Java []\nclass Solution {\n    public int maxPower(String s) {\n        int prev = s.charAt(0);\n        int count = 1;\n        int maxcount = 1;\n\n        for (int i = 1; i < s.length(); i++){\n            if (s.charAt(i) == prev){\n                count++;\n            }\n            else{\n                prev = s.charAt(i);\n                count = 1;\n            }\n            maxcount = Math.max(maxcount,count);\n        }\n        return maxcount;\n    }\n}\n```
['String', 'Python', 'Java', 'Python3']