백준 30329번: Kick #Python

ColorlessDia·2024년 9월 19일

algorithm/baekjoon

목록 보기
305/808
from collections import deque

s = input()

stack = deque()
count = 0

for c in s:
    stack.append(c)

    if len(stack) < 4:
        continue
    
    if stack[-1] != 'k':
        continue
    
    temp = ''

    for i in reversed(range(1, 4 + 1)):
        temp += stack[-i]
    
    if temp == 'kick':
        count += 1

print(count)

0개의 댓글