Java O(n) solution
```\nclass Solution {\n    public int maxPower(String s) {\n        int n = s.length(), ans = 0, count = 1;\n        for (int i = 0; i < n; ++i) {\n            
```\nclass Solution {\n    public int maxPower(String s) {\n        int n = s.length(), ans = 0, count = 1;\n        for (int i = 0; i < n; ++i) {\n            if (i == n - 1 || s.charAt(i) != s.charAt(i + 1)) {\n                ans = Math.max(ans, count);\n                count = 1;   \n            }\n            else {\n                count++;\n            }\n        }\n        return ans;\n    }\n}
[]