🔥*Dry Run*🧑‍💻 + Efficient Explanation🧠 (Beats 100% solutions)🔥
Intuition\nThe problem asks to find the maximum length of a substring where all the characters are the same. This involves counting the longest consecutive sequ
# Intuition\nThe problem asks to find the maximum length of a substring where all the characters are the same. This involves counting the longest consecutive sequence of identical characters.\n\n# Approach\n1. **Initialize Counters**:\n   - `count` to track the current length of the substring of identical characters.\n   - `maxi` to keep track of the maximum length found so far.\n2. **Iterate Through the String**:\n   - For each character in the string, check if it is the same as the previous character.\n   - If it is, increment the `count`.\n   - If it isn\'t, update `maxi` if the current `count` is greater than `maxi`, then reset `count` to 1.\n3. **Final Check**:\n   - After the loop, ensure to update `maxi` one last time in case the longest substring ends at the last character.\n\n# Complexity\n- Time complexity:\n  $$O(n)$$ where `n` is the length of the string. We traverse the string once.\n\n- Space complexity:\n  $$O(1)$$ as we use a constant amount of extra space.\n\n# Dry Run\nLet\'s dry run the example `s = "abbcccddddeeeeedcba"`:\n\n1. **Initialize**:\n   - `count = 1`\n   - `maxi = 0`\n\n2. **Iterate**:\n   - At `i = 1`, `s[1] == s[0]` (both \'b\'): `count = 2`\n   - At `i = 2`, `s[2] != s[1]`: `maxi = 2`, `count = 1`\n   - At `i = 3`, `s[3] == s[2]` (both \'c\'): `count = 2`\n   - At `i = 4`, `s[4] == s[3]` (both \'c\'): `count = 3`\n   - At `i = 5`, `s[5] != s[4]`: `maxi = 3`, `count = 1`\n   - At `i = 6`, `s[6] == s[5]` (both \'d\'): `count = 2`\n   - Continue this process...\n   - Final `maxi = 5` for substring "eeeee".\n\nThe dry run confirms that the function correctly calculates the maximum power of consecutive identical characters in the string.\n# Code\n```\nclass Solution {\npublic:\n    int maxPower(string s) {\n        if(s.length() == 1) { \n            return 1;\n        }\n        int count = 1 ; \n        int maxi = 0;\n        for(int i = 1 ; i < s.length(); i++){\n            if(s[i]==s[i-1]){\n                count++ ; \n            }\n            else{\n                maxi = max(count , maxi );\n                count = 1;\n            }\n        }\n        return (count < maxi ) ? maxi : count ;\n    }\n};\n```
['String', 'C++']