Leetcode 1542 Solution
This article provides solution to leetcode question 1542 (consecutive-characters)
Access this page by simply typing in "lcs 1542" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/consecutive-characters
Solution
class Solution:
def maxPower(self, s: str) -> int:
res = 0
last_ch = None
cur_len = 0
for ch in s:
if ch == last_ch:
cur_len += 1
else:
cur_len = 1
res = max(res, cur_len)
last_ch = ch
return res