전체 글2846 [프로그래머스/Java] 유한소수 판별하기 -Codeclass Solution { public int solution(int a, int b) { int n = b / getGcd(a, b); while (n != 1) { if (n % 5 == 0) n /= 5; else if (n % 2 == 0) n /= 2; else return 2; } return 1; } public static int getGcd(int n1, int n2) { return n1 % n2 == 0 ? n2 : getGcd(n2, n1 % n2); }}while문 종료 조건을 잘 못찾아서 힌트등을 보고 해결했습니다. 2025. 2. 21. [프로그래머스/Java] 등수 매기기 -Codeimport java.util.*;import java.util.stream.Collectors;class Solution { public int[] solution(int[][] score) { int[] answer = new int[score.length]; List sorted_list = Arrays.stream(score) .map(arr -> (arr[0] + arr[1])) .mapToInt(Integer::intValue) .boxed().collect(Collectors.toList()); sorted_list.sort(Comparator.reverseOr.. 2025. 2. 21. [프로그래머스/Java] 문자열 밀기 -Codeclass Solution { public int solution(String A, String B) { if (A.equals(B)) return 0; int cnt = 0; for (int i = 0; i 2025. 2. 21. [프로그래머스/Java] 다음에 올 숫자 -Codeclass Solution { public int solution(int[] common) { int len = common.length - 1; if (len == 1) return common[1] * 2 - common[0]; int[] gaps = new int[2]; for (int i = 1; i 2025. 2. 21. [프로그래머스/Java] OX퀴즈 -Codeclass Solution { public String[] solution(String[] quiz) { String[] answer = new String[quiz.length]; for (int i = 0; i 2025. 2. 21. [프로그래머스/Java] 저주의 숫자 3 -Codeimport java.util.*;class Solution { public int solution(int n) { int answer = 1; int now = 1; while (now 2025. 2. 21. 이전 1 2 3 4 ··· 475 다음