def solution(cards1, cards2, goal):
answer = "Yes"
idx1 = 0
idx2 = 0
for g in goal:
if idx1 < len(cards1) and g == cards1[idx1]:
idx1 += 1
elif idx2 < len(cards2) and g == cards2[idx2]:
idx2 += 1
else:
answer = "No"
break
return answer
더 자세한 설명은 내 티스토리에
https://jiwonna52.tistory.com/18