링크 : https://school.programmers.co.kr/learn/courses/30/lessons/64061
#include <string>
#include <vector>
using namespace std;
int solution(vector<vector<int>> board, vector<int> moves) {
vector<int> stack(0, 0);
int answer = 0;
for(int i = 0; i < moves.size(); i++){
int num = moves[i] - 1;
for(int j = 0; j < board.size(); j++){
if(board[j][num] != 0){
stack.push_back(board[j][num]);
board[j][num] = 0;
if(stack.size() >= 2){
if(stack.at(stack.size()-1) == stack.at(stack.size()-2)){
answer += 2;
stack.pop_back();
stack.pop_back();
}
}
break;
}
}
}
return answer;
}