[Algorithm] [백준] 1439 - 뒤집기 (그리디)

myeonji·2022년 3월 10일
0

Algorithm

목록 보기
76/89

0->1 혹은 1->0이 되는 반환점을 기록한다!!!

s = input()

lst = []
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        lst.append(i)

if (len(lst)%2) == 0:  # 변화되는 부분이 짝수개 이면
    print(len(lst)//2)
elif (len(lst)%2) == 1:
    print((len(lst)//2)+1)

0개의 댓글