Problem link
https://leetcode.com/problems/consecutive-characters/
Problem Summary
연속된 문자 중 가장 긴 길이를 구하는 문제.
Solution
그냥 돌면서 구하면 된다... 이걸 글로 써야 하나 고민했지만 푼 문제니까 그냥 올리기로 결정.
Source Code
class Solution:
def maxPower(self, s: str) -> int:
ans = 1
cnt = 1
for i in range(1, len(s)):
if s[i] == s[i - 1]:
cnt += 1
else:
ans = max(ans, cnt)
cnt = 1
return max(ans, cnt)