-
[python]백준 연속구간 2495번알고리즘 문제풀이/백준(파이썬) 2023. 5. 14. 21:47
코드
import sys sys.stdin = open("2495.txt", "r") for _ in range(3): q=list(input()) s=1 w=0 for i in range(1,len(q)): if q[i]==q[i-1]: s+=1 #실행하면 w=s #현재 s의 값 else: #실행하면 w=1 w=max(s,w) s=1 w=max(s,w) print(w) #기본값은 1(s) #현재 인덱스에서 인덱스-1 같다면 s+1 #아니면 w리스트에 추가 s그리고 s=1
링크
https://www.acmicpc.net/problem/2495
'알고리즘 문제풀이 > 백준(파이썬)' 카테고리의 다른 글
[python]백준 점수계산 2506번 (0) 2023.05.16 [python]백준 2017 연세대학교 프로그래밍 경시대회 14568번 (0) 2023.05.15 [python]백준 0123456789 6916번 (1) 2023.05.13 [python]백준 공 1547번 (0) 2023.05.12 [python]백준 핸드폰 요금 1267번 (0) 2023.05.11