본문 바로가기

Java612

[백준/Java] 1707번 이분 그래프 -Codeimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.StringTokenizer;public class BOJ1707 { static ArrayList[] graph; static int[] check; static boolean[] visited; static boolean isEven; public static void main(String[] args) throws IOException { BufferedReader br = new Buff.. 2025. 11. 19.
[백준/Java] 34691번 대전과학고등학교를 사랑하십니까? -Codeimport java.util.Scanner;public class BOJ34691 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { String line = sc.next(); // 탈출 조건 if (line.equals("end")) break; // 출력 System.out.println(solution(line)); } sc.close(); } static String solution(Strin.. 2025. 11. 19.
[프로그래머스/Java] 카펫 -Codeclass Solution { public int[] solution(int brown, int yellow) { int total = brown + yellow; for (int h = 3; h yellow의 경우도 확인해야 하는데 해당 부분을 처음에 빠뜨려서 그걸 고치고 해결했습니다. 2025. 11. 18.
[프로그래머스/Java] 귤 고르기 -Codeimport java.util.*;class Solution { public int solution(int k, int[] tangerine) { int answer = 0; Map map = new HashMap(); // 값을 map으로 count for (int el : tangerine) { map.put(el, map.getOrDefault(el, 0) + 1); } List keySet = new ArrayList(map.keySet()); // 가장 많이 가지고 있는 크기의 사과 부터 갯수 빼기 위한 정렬 keySet.sort((o1, o2) -> map.ge.. 2025. 11. 18.
[백준/Java] 10426번 기념일 2 -Codeimport java.util.HashMap;import java.util.Map;import java.util.Scanner;public class BOJ10426 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String date = sc.next(); int add = sc.nextInt(); // 년월일 분리 String[] parts = date.split("-"); int year = Integer.parseInt(parts[0]); int month = Integer.parseInt(parts[.. 2025. 11. 18.
[LeetCode/Java] 14. Longest Common Prefix -Codeclass Solution { public String longestCommonPrefix(String[] strs) { int minStrLength = getMinLength(strs); int totalLength = strs.length; StringBuilder sb = new StringBuilder(); for (int i = 0; i 2025. 11. 18.