Consecutive Characters LeetCode solution in Python

1
# Runtime: 30 ms (Top 32.1%) | Memory: 13.25 MB (Top 75.9%)
2

3

4
class Solution(object):
5
def maxPower(self, s):
6
"""
7
:type s: str
8
:rtype: int
9
"""
10
stack = []
11
mxpow = 0
12
for i in s:
13
if stack and stack[-1] != i:
14
mxpow = max(mxpow, len(stack))
15
stack = []
16
stack.append(i)
17
else:
18
stack.append(i)
19
mxpow = max(mxpow, len(stack))
20
return mxpow

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0