목록K번째수 (2)
drexqq
import java.util.Arrays; class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = {}; answer = new int[commands.length]; for (int i = 0; i < commands.length; i++) { int[] temp = new int[commands[i][1]-commands[i][0]+1]; int index = 0; for (int j = commands[i][0]-1; j < commands[i][1]; j++) { temp[index] = array[j]; index++; } Arrays.sort(temp); answer[i] = temp[comm..
class Solution { public int solution(int[][] board, int[] moves) { int answer = 0; Stack basket = new Stack(); for (int i = 0; i < moves.length; i++) { for (int j = 0; j < board.length; j++) { if (board[j][moves[i]-1] != 0) { if (basket.isEmpty()) { basket.push(board[j][moves[i]-1]); } else { if (basket.peek() == board[j][moves[i]-1]) { basket.pop(); answer += 2; } else { basket.push(board[j][mo..