백준/Greedy

[그리디/백준] 12904번: A와 B

ydin 2022. 7. 13. 16:45

-문제: https://www.acmicpc.net/problem/12904

 

스스로 푼 문제!

Gold Level5 

코테에서 자주 나오는 유형이 x에서 y로 변환시키는 것에 대한 문제에서는 y에서 x로 역순으로 가면서 푸는 것이다. 

 

-정답풀이:

s=list(input())
t=list(input())

while True:
    if len(t)==len(s) :
        if t==s:
            print(1)
            break
        else:
            print(0)
            break
    if t[-1]=='A':
        t=t[:-1]
    elif t[-1]=='B':
        t=t[:-1]
        t.reverse()