Leetcode 分享筆記

1446. Consecutive Characters
等級: Easy

原始題目連結請點此

leetcode
class Solution(object):
    def maxPower(self, s):
        """
        :type s: str
        :rtype: int
        """
        max_num, count = 1,1
        for i in range(0, len(s)-1):
            if (s[i] == s[i+1]):
                count = count + 1
                if(count > max_num):
                    max_num = count
            else:
                count = 1
        return max_num