728x90
from collections import deque
def solution(board, moves):
answer = 0
# moves-1 위치에 있는 것 뽑기
temp = deque()
for i in range(0,len(moves)):
index = moves[i]-1
for j in range(0,len(board)):
if board[j][index]!=0:
if len(temp)!=0:
if temp[-1]==board[j][index]:
answer+=2
temp.pop()
board[j][index]=0
break
else:
temp.append(board[j][index])
board[j][index]=0
break
else:
temp.append(board[j][index])
board[j][index]=0
break
return answer728x90
'🟢 알고리즘 문제 풀이 > Programmers' 카테고리의 다른 글
| [파이썬] 프로그래머스 프로세스 (0) | 2023.08.21 |
|---|---|
| [파이썬] 프로그래머스 연속 펄스 부분 수열의 합 (0) | 2023.06.09 |
| [파이썬] 프로그래머스 무인도 연습 (0) | 2023.05.24 |
| [파이썬] 백준 10159 저울 (0) | 2023.05.08 |
| [파이썬] 프로그래머스 연속된 부분 수열의 합 (0) | 2023.04.26 |