https://programmers.co.kr/learn/courses/30/lessons/64061
def solution(board, moves):
n = len(board)
stack = []
count = 0
for m in moves:
if board[n - 1][m - 1] == 0:
continue
for i in range(n):
if board[i][m - 1] != 0:
stack.append(board[i][m - 1])
if len(stack) >= 2 and stack[-1] == stack[-2]:
count += 2
stack.pop()
stack.pop()
board[i][m - 1] = 0
break
return count