Java | 100% Faster | Explained | Simplest Solution | O(N)
We will be checking if subsequent characters are equal, if yes we will keep on incrementing the count otherwise we will store the new value in max if count > ma
We will be checking if subsequent characters are equal, if yes we will keep on incrementing the count otherwise we will store the new value in max if count > max.\n```\nclass Solution {\n    public int maxPower(String s) {\n\t\t// Taking max & count as 1 since minimum length of substring can be 1\n        int max = 1, count = 1;\n        for(int i=0;i<s.length()-1;i++) {\n            if(s.charAt(i)!=s.charAt(i+1)) {\n\t\t\t\t// If the subsequent characters are not equal, then compare the count with max & update if required\n                max = Math.max(max, count);\n\t\t\t\t// Reset count as 1, to check on remaining string\n                count = 1;\n                continue;\n            }\n            else\n                count ++;\n        }     \n\t\t// Incase of "abcc", max = 1, but count = 2, so we will be returning the max of them\n        return Math.max(max, count);\n    }\n}\n```
['Java']