티스토리 뷰
programmers.co.kr/learn/courses/30/lessons/64061
코딩테스트 연습 - 크레인 인형뽑기 게임
[[0,0,0,0,0],[0,0,1,0,3],[0,2,5,0,1],[4,2,4,4,2],[3,5,1,3,1]] [1,5,3,5,1,2,1,4] 4
programmers.co.kr
def solution(board, moves):
answer = 0
basket = []
cnt = -1 // basket의 길이를 저장하는 변수
for move in moves:
for i in range(len(board)):
if board[i][move-1] != 0:
basket.append(board[i][move-1])
board[i][move-1] = 0
cnt += 1
if cnt >= 1 and basket[cnt] == basket[cnt-1]:
basket = basket[:-2]
cnt -= 2
answer += 2
break
return answer'Algorithm > Programmers' 카테고리의 다른 글
| [프로그래머스] 주식가격 - Python (0) | 2021.03.25 |
|---|---|
| [프로그래머스] 프린터 - Python (0) | 2021.03.25 |
| [프로그래머스] 정수 삼각형 - Python (0) | 2021.03.12 |
| [프로그래머스] 도둑질 - Python (0) | 2021.03.12 |
| [프로그래머스] 베스트앨범 - Python (0) | 2021.03.03 |
