
(Java) 프로그래머스 크레인 인형뽑기 게임
·
코딩 테스트
바로 스택으로 풀어야겠다는 생각이 든 문제였다. 인형을 세로로 뽑기 때문에 세로로 바꿨는데 다른 분들이 푼 답을 보면 바꿀 필요는 없는 것 같다. 최종 코드 import java.util.Stack; class Solution { public int solution(int[][] board, int[] moves) { int answer = 0; // 인형을 담을 스택 Stack st = new Stack(); // 인형 세로배열로 바꾸기 int[][] temp = new int[board.length][board[0].length]; for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[i].length; j++) { temp[i][j]..