Beakjoon&프로그래머스/Java457 [프로그래머스/Java] [PCCE 기출문제] 9번 / 이웃한 칸 -Codeclass Solution { public int solution(String[][] board, int h, int w) { int answer = 0; int[] dx = {-1, 1, 0, 0}; int[] dy = {0, 0, -1, 1}; String now = board[h][w]; for (int i = 0; i = board.length || y = board[0].length) { continue; } if (board[x][y].equals(now)) { answer++; } } .. 2025. 3. 9. [프로그래머스/Java] 대충 만든 자판 -Codeimport java.util.*;class Solution { public int[] solution(String[] keymap, String[] targets) { int[] answer = new int[targets.length]; Map map = new HashMap(); for (String key : keymap) { for (int i = 0; i map말고 다른 방식으로 풀다가 틀려서 질문을 보고 map과 getOrDefault를 보고 힌트를 얻어서 해결했습니다. 2025. 3. 7. [프로그래머스/Java] 로또의 최고 순위와 최저 순위 -Codeimport java.util.*;import java.util.stream.Collectors;class Solution { public int[] solution(int[] lottos, int[] win_nums) { List win_list = Arrays.stream(win_nums) .boxed().collect(Collectors.toList()); int current_cnt = 0, zero_cnt = 0; for (int n : lottos) { if (n == 0) { zero_cnt++; continue; } .. 2025. 3. 1. [프로그래머스/Java] 괄호 회전하기 -Codeimport java.util.*;class Solution { public int solution(String s) { int answer = 0; int len = s.length(); Deque deq = new ArrayDeque(); for (int i = 0; i 2025. 3. 1. [프로그래머스/Java] N개의 최소공배수 -Codeclass Solution { public int solution(int[] arr) { int answer = 1; for (int num : arr) { answer = answer * num / getGcd(num, answer); } return answer; } public static int getGcd(int num1, int num2) { return num2 == 0 ? num1 : getGcd(num2, num1 % num2); }} 2025. 3. 1. [프로그래머스/Java] 영어 끝말잇기 -Codeimport java.util.*;class Solution { public int[] solution(int n, String[] words) { int wrong = 0; int num = 0; int turn = 0; List wordsList = new ArrayList(); for (int i = 0; i 2025. 2. 28. 이전 1 2 3 4 ··· 77 다음