백준 / 뒤집기 / 1439

박성완·2022년 4월 10일
0

백준

목록 보기
61/78
post-thumbnail

Question

문제링크
Silver 3

Logic

  1. 입력된 문자열을 '0 덩어리의 갯수'와 '1 덩어리의 갯수'로 나눠서 센다.
  2. 둘 중 낮은 수를 출력한다.

Code

from sys import stdin

count = [0,0]
prev = 2
for s in stdin.readline().rstrip():
    if s != prev : count[int(s)]+=1
    prev = s

print(min(count))

0개의 댓글