문제링크: 카드 뭉치
✍🏻 Information
| content | |
|---|---|
| 언어 | python |
| 난이도 | ⭐️ |
| 풀이시간 | 5분 |
| 제출횟수 | 1 |
| 인터넷검색유무 | no |
🍒 My Code
def solution(cards1, cards2, goal):
one, two = 0, 0
for i in range(len(goal)):
if one<len(cards1) and cards1[one]==goal[i]:
one+=1
elif two<len(cards2) and cards2[two]==goal[i]:
two+=1
else:
return "No"
return "Yes"
💡 What I learned
def solution(cards1, cards2, goal):
for g in goal:
if len(cards1) > 0 and g == cards1[0]:
cards1.pop(0)
elif len(cards2) >0 and g == cards2[0]:
cards2.pop(0)
else:
return "No"
return "Yes"