본문 바로가기

Algorithm255

[Programmers] Lv.0 | 외계어 사전 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/120869 풀이import java.util.*;class Solution { public int solution(String[] spell, String[] dic) { boolean found = Arrays.stream(dic) .anyMatch(word -> { for (String s : spell) { int count = word.length() - word.replace(s, "").length(); if (count != 1) { .. 2025. 9. 27.
[Programmers] Lv.0 | 저주의 숫자 3 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/120871 풀이class Solution { public int solution(int n) { int answer = 0; int count = 0; while (count 2025. 9. 26.
[Programmers] Lv.0 | 평행 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/120875 풀이class Solution { public int solution(int[][] dots) { // 점들을 꺼내서 변수에 저장 int x1 = dots[0][0], y1 = dots[0][1]; int x2 = dots[1][0], y2 = dots[1][1]; int x3 = dots[2][0], y3 = dots[2][1]; int x4 = dots[3][0], y4 = dots[3][1]; int answer = 0; // 조합 1: (0,1) vs (2,3) double .. 2025. 9. 26.
[Programmers] Lv.0 | [PCCE 기출문제] 4번 / 병과분류 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340204 풀이import java.util.Scanner;public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String code = sc.next(); String lastFourWords = code.substring(code.length()-4, code.length()); if(lastFourWords.equals("_eye")){ System.out.println("Op.. 2025. 9. 22.
[Programmers] Lv.0 | [PCCE 기출문제] 6번 / 물 부족 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340202 풀이class Solution { public int solution(int storage, int usage, int[] change) { int total_usage = 0; for(int i=0; i storage){ return i; } } return -1; }} 2025. 9. 22.
[Programmers] Lv.0 | [PCCE 기출문제] 5번 / 심폐소생술 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340203 풀이class Solution { public int[] solution(String[] cpr) { int[] answer = {0, 0, 0, 0, 0}; String[] basic_order = {"check", "call", "pressure", "respiration", "repeat"}; for(int i=0; i 2025. 9. 19.
[Programmers] Lv.0 | [PCCE 기출문제] 3번 / 수 나누기 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340205 풀이import java.util.Scanner;public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int number = sc.nextInt(); int answer = 0; for(; number > 0; ) { answer += number % 100; number /= 100; } System.out.println(an.. 2025. 9. 17.
[Programmers] Lv.0 | [PCCE 기출문제] 2번 / 각도 합치기 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340206 풀이import java.util.Scanner;public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int angle1 = sc.nextInt(); int angle2 = sc.nextInt(); int sum_angle = angle1 + angle2; System.out.println(sum_angle % 360); }} 2025. 9. 17.
[Programmers] Lv.0 | [PCCE] 기출문제 1번 / 문자 출력 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/340207 풀이import java.util.Scanner;public class Solution { public static void main(String[] args) { String message = "Let's go!"; System.out.println("3\n2\n1"); System.out.println(message); }} 2025. 9. 17.
[Programmers] Lv.0 | 겹치는 선분의 길이 | Java 문제https://school.programmers.co.kr/learn/courses/30/lessons/120876 포인트연속된 숫자로 구간을 표현할 때, 끝점은 포함하지 않아도 됨 풀이class Solution { public int solution(int[][] lines) { int[] arr = new int[200]; int answer = 0; for (int i = 0; i 1) { answer++; } } return answer; }}import java.util.*;class Solution { public int solution(int[][].. 2025. 3. 11.
[Programmers] Lv.0 / 유한소수 판별하기 / Java 문제 풀이import java.util.*;class Solution { public int solution(int a, int b) { int reducedDenominator = b / gcd(a, b); // 기약분수로 바꾸기 위해 b를 GCD로 나눔 while (reducedDenominator != 1) { // reducedDenominator가 1이 될 때까지 if (reducedDenominator % 2 == 0) { // 2로 나눠지면 나누기 reducedDenominator /= 2; } else if (reducedDenominator % 5 == 0) { // 5로 나눠지.. 2025. 2. 26.
[Programmers] Lv.0 / 특이한 정렬 / Java 문제 풀이import java.util.*;class Solution { public int[] solution(int[] numlist, int n) { Arrays.sort(numlist); for (int i = 0; i import java.util.*;class Solution { public int[] solution(int[] numlist, int n) { return Arrays.stream(numlist) .mapToObj(a -> (Integer) a) // 1. int[] 배열을 Integer 객체 스트림으로 변환 .sorted((a, b) -> { // 2. 커스텀 비교 함수로 정.. 2025. 2. 11.