EASIEST APPROACH 🤤||✅ 💯% ON RUNTIME ||✌️😎 WITH EXPLNATION
Intuition\nThe problem asks to find the maximum consecutive occurrences of the same character in the given string s.\n\n# Approach\nWe can iterate through the c
# Intuition\nThe problem asks to find the maximum consecutive occurrences of the same character in the given string `s`.\n\n# Approach\nWe can iterate through the characters of the string `s` and keep track of the count of consecutive occurrences of the same character. We use two variables, `count` to keep track of the current count of consecutive occurrences and `max` to store the maximum count encountered so far. If the current character is the same as the previous one, we increment the count and update the maximum count. If the current character is different from the previous one, we reset the count to zero. Finally, we return the maximum count plus one because the count represents the number of consecutive occurrences of the same character, and adding one accounts for the current character itself.\n\n# Complexity\n- Time complexity: \\( O(n) \\), where \\( n \\) is the length of the input string `s`. We iterate through the string once to calculate the maximum consecutive occurrences.\n  \n- Space complexity: \\( O(n) \\), where \\( n \\) is the length of the input string `s`. We use an array of characters to store the characters of the string.\n\n# Code\n```java\nclass Solution {\n    public int maxPower(String s) {\n        int count = 0; \n        int max = 0;  \n        char[] array = s.toCharArray(); \n        \n        for (int i = 1; i < s.length(); i++) {\n            if (array[i - 1] == array[i]) {\n                count++; \n                max = Math.max(max, count);  \n            } else {\n                count = 0; \n            }\n        }\n        \n        return max + 1;\n    }\n}\n```
['String', 'Counting', 'Java']