교육과정 설계

이세진·2022년 4월 15일
0

코테준비

목록 보기
38/87

생성일: 2022년 1월 28일 오후 6:46

구현 코드

# 교육과정 설계 (큐)
import sys
from collections import deque
sys.stdin = open("input.txt", "rt")
subjects = input()
n = int(input())

for i in range(n):
    s = input()
    Q = deque(subjects)
    for x in s:
        if x in Q:
            if x == Q[0]:
                sub = Q.popleft()
            else:
                print(f"#{i+1} NO")
                break
        else:
            pass
    else:
        if len(Q) >= 1:
            print(f"#{i+1} NO")
        else:
            print(f"#{i+1} YES")
  • String 타입도 deque로 바로 변환 가능 (굳이 리스트로 변환해서 deque로 만들 필요 없다)
profile
나중은 결코 오지 않는다.

0개의 댓글