백준 15786번: Send me the money #Python

ColorlessDia·2024년 11월 30일

algorithm/baekjoon

목록 보기
377/808
import sys

N, M = map(int, sys.stdin.readline().split())
S = sys.stdin.readline().rstrip()

for _ in range(M):
    line = sys.stdin.readline().rstrip()

    i = 0

    for char in line:
        target = S[i]

        if char != target:
            continue
        
        i += 1
        
        if N <= i:
            break
    
    print('true') if N == i else print('false')

0개의 댓글