250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록프로그래머스 알고리즘 (225)
N
(프로그래머스 c++ KAKAO) 1단계- 크레인 인형뽑기
스택을 이용해서 푸는 문제. 이중 for문을 이용하여 0이 아닌 값을 board에서 찾아낸 후 스택에 push. 만약 스택의 top과 board[j][moves[i] - 1]의 값과 같다면 같은 인형이니 answer += 2를 한 후, 스택을 pop 해준다. #include #include #include #include using namespace std; int solution(vector board, vector moves) { int answer = 0; int size = board[moves[0] - 1].size(); stack stk; for(int i = 0; i < moves.size(); i++) { for(int j = 0; j < size; j++) { if(board[j][mov..
프로그래머스 알고리즘/KAKAO
2020. 4. 14. 14:30