Posted on

Description

Submission

class Solution {
public:
    int maxPower(string s) {
        int cnt = 0;
        char prev = s[0];

        int ret = 0;
        for(char ch: s) {
            if(ch == prev) ++cnt;
            else {
                cnt = 1;
            }
            prev = ch;
            ret = max(ret, cnt);
        }

        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *