728x90
반응형
기본적인 문자열 문제이다.
N = int(input())
M = int(input())
s = input()
i = cnt = p = 0
while i < M-2:
if s[i] == 'I' and s[i+1] == 'O' and s[i+2] == 'I':
i += 2
p += 1
if p == N:
p -= 1
cnt += 1
else:
i += 1
p = 0
print(cnt)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 9095번 1, 2, 3 더하기(python) (0) | 2021.03.18 |
---|---|
백준 알고리즘 9019번 DSLR(python) (0) | 2021.03.18 |
백준 알고리즘 2579번 계단 오르기(python) (0) | 2021.03.18 |
백준 알고리즘 1620번 나는야 포켓몬 마스터 이다솜(python) (0) | 2021.03.18 |
백준 알고리즘 11652번 카드(python) (0) | 2021.03.18 |