입출력 예시
cards1 | cards2 | goal | result |
["i", "drink", "water"] | ["want", "to"] | ["i", "want", "to", "drink", "water"] | "Yes" |
["i", "water", "drink"] | ["want", "to"] | ["i", "want", "to", "drink", "water"] | "No" |
나의 코드
def solution(cards1, cards2, goal):
for x in goal:
if cards1 and x == cards1[0]:
cards1.pop(0)
elif cards2 and x == cards2[0]:
cards2.pop(0)
else:
return 'No'
return 'Yes'
Python
복사