[프로그래머스] 크레인 인형뽑기 게임

Doodung·2021년 7월 15일
0

코딩테스트

목록 보기
2/8
from collections import deque
def solution(board, moves):
    temp=deque()
    j,k,answer=0,0,0
    length=len(moves)
    
    for i in range(0,length):
        for j in range(0,len(board)):
            if(board[j][moves[i]-1]==0):
                continue
            else:
                temp.append(board[j][moves[i]-1])
                k+=1
                if(len(temp)>=2):
                    if(temp[k-2]==temp[k-1]):
                        temp.pop()
                        temp.pop()
                        k-=2
                        answer+=2
                board[j][moves[i]-1]=0
                break

    return answer
profile
반가워요!

0개의 댓글