백준 30700번: KOREA 문자열 만들기 #Python

ColorlessDia·2024년 11월 21일

algorithm/baekjoon

목록 보기
368/836
S = input()

target_list = ['K', 'O', 'R', 'E', 'A']

length = 0
index = 0

for s in S:

    if s == target_list[index]:
        length += 1
        index += 1
    
    if index == len('KOREA'):
        index = 0

print(length)

0개의 댓글