백준(BOJ) 풀이

[백준 9935] 문자열 폭발

오호라-노이혼 2019. 11. 19. 17:53

import sys
s=sys.stdin.readline().rstrip()
bomb=sys.stdin.readline().rstrip()
stack=[]
for i in s:
    stack.append(i)
    if i==bomb[-1] :
        temp=""
        for j in stack[len(bomb)*(-1):]:
            temp+=j
        if temp==bomb:
            del stack[len(bomb)*(-1):]
if len(stack)==0:
    print("FRULA")
else:
    print(*stack, sep="")