목표 문자열에서 정답을 추론하는 과정이 중요
https://school.programmers.co.kr/learn/courses/30/lessons/159994
def solution(cards1, cards2, goal):
before_index1 = 0
after_index1 = 0
before_index2 = 0
after_index2 = 0
for i in goal:
if i in cards1:
before_index1 = after_index1
after_index1 = cards1.index(i)
if after_index1 - before_index1 != 1 and after_index1 != 0:
return "No"
if i in cards2:
before_index2 = after_index2
after_index2 = cards2.index(i)
if after_index2 - before_index2 != 1 and after_index2 != 0:
return "No"
return "Yes"