본문 바로가기
python-algorithm

백준 2495 연속구간

by 무적김두칠 2021. 11. 2.

1
2
3
4
5
6
7
8
9
10
11
12
for _ in range(3):
    s = str(input())
    mymax = 1
    cnt = 1
    for i in range(1,len(s)):
        if s[i]==s[i-1]:
            cnt+=1
        else:
            mymax=max(cnt,mymax)
            cnt=1
    mymax = max(cnt, mymax)
    print(mymax)
cs
반응형

댓글