2
public int maxPower(String s) {3
// O(n), assuming the access to every char is O(1)4
// iterate through characters5
// if char(n) == char(n+1) counter++6
// if counter > max, max = counter7
// else counter = 1 // 1 is init value because otherwise the compared char itself is not counted10
1; // 1 is init value because otherwise the compared char itself is not counted11
int counterConsecutive = 1;12
for (int i = 0; i < s.length() - 1; i++) {13
if (s.charAt(i) == s.charAt(i + 1)) {15
maxConsecutive = Math.max(counterConsecutive, maxConsecutive);17
counterConsecutive = 1;21
return maxConsecutive;