The power of the string is the maximum length of a non-empty substring that contains only one unique character.

Given a string s, return the power of s.

&nbsp;
Example 1:

Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.


Example 2:

Input: s = "abbcccddddeeeeedcba"
Output: 5
Explanation: The substring "eeeee" is of length 5 with the character 'e' only.


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 500
	s consists of only lowercase English letters.


class Solution(object):
    def maxPower(self, s):
        """
        :type s: str
        :rtype: int
        """
        stack=[]
        mxpow=0
        for i in s:
            if stack and stack[-1]!=i:
                mxpow=max(mxpow,len(stack))
                stack=[]
                stack.append(i)
            else:
                stack.append(i)
        mxpow=max(mxpow,len(stack))
        return mxpow
class Solution {
    public int maxPower(String s) {
        // O(n), assuming the access to every char is O(1)
        // iterate through characters
        // if char(n) == char(n+1) counter++
            // if counter > max, max = counter
        // else counter = 1 // 1 is init value because otherwise the compared char itself is not counted

        int maxConsecutive = 1; // 1 is init value because otherwise the compared char itself is not counted
        int counterConsecutive = 1;
        for(int i = 0; i< s.length()-1; i++){
            if(s.charAt(i) == s.charAt(i+1)){
                counterConsecutive++;
                maxConsecutive = Math.max(counterConsecutive, maxConsecutive);
            } else {
                counterConsecutive = 1;
            }
        }

        return maxConsecutive;
    }
}
class Solution {
public:
    int ans = 1 ;
    int maxPower(string s) {
        for(int i = 0 ; i < size(s) ; ++i ){
            int j = i ;
            while(j < size(s) and s[j] == s[i]) ++j ;
            ans = max(ans,j-i);
            i = j - 1 ;
        }
        return ans ;
    }
};
var maxPower = function(s) {
    let count = 1;
    let maxNum =1;

    for(let i=0;i<s.length;i++){
       (s[i]===s[Number(i)+1]) ? count++ : count=1;
        maxNum = Math.max(count,maxNum);
    }

    return maxNum;
};
Consecutive Characters