알고리즘

[프로그래머스] 카드 뭉치

HHB 2023. 10. 7. 18:59
def solution(cards1, cards2, goal):
    while True:
        if len(goal) == 0:
            return "Yes"
        
        if len(cards1) != 0:
            if cards1[0] == goal[0]:
                cards1.remove(cards1[0])
                goal.remove(goal[0])
                continue
                
        if len(cards2) != 0:
            if cards2[0] == goal[0]:
                cards2.remove(cards2[0])
                goal.remove(goal[0])
                continue
        
        return "No"
728x90
반응형
LIST