본문 바로가기

백준27

접두사 찾기 - JAVA, Trie 구조 출처 : https://www.acmicpc.net/problem/14426 코드 & 풀이 import java.util.*;import java.io.*;public class 백준_접두사찾기_14426 { static class TrieNode { Map children = new HashMap(); } static class Trie { TrieNode root = new TrieNode(); void inset(String word) { TrieNode node = root; for (char ch : word.toCharArray()) { node = node.child.. 2025. 6. 28.
팀 빌딩 - JAVA, two pointer 출처 : https://www.acmicpc.net/problem/22945 코드 & 풀이 import java.io.*;import java.util.*;public class 백준_팀빌딩_22945 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); StringTokenizer st = new StringTokenizer(br.readLine()); int[] status = n.. 2025. 6. 9.
보이저 1호 - JAVA, 구현 출처 : https://www.acmicpc.net/problem/3987 코드 & 풀이 import java.io.*;import java.util.*;public class 백준_보이저1호_3987 { static int N, M; static int max_count; static int result_direct; static boolean is_voyager; static char[][] space; static int[] dx = {-1, 0, 1, 0}; // U R D L static int[] dy = {0, 1, 0, -1}; static int[][] mirror = { // /, \ {1, 3}, .. 2025. 6. 7.
두 개의 탑 - JAVA, Two Pointer, Prefix Sum 출처 : https://www.acmicpc.net/problem/2118 코드 & 풀이 import java.io.*;public class 백준_두개의탑_2118 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] dist = new int[N]; for (int i = 0; i prefix 배열의 길이가 2배인 이유 ⇒ 5에서부터 시작하는 경우도 있으니까end의 .. 2025. 6. 6.
백준 1300. K 번째 수 - JAVA, 이분 탐색 출처 : https://www.acmicpc.net/problem/1300 코드 & 풀이 import java.io.*;public class 백준_K번째수_1300 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int K = Integer.parseInt(br.readLine()); int low = 1; int high = K; int answer =.. 2025. 5. 23.
백준19238.스타트 택시 - JAVA, 구현, HashMap, List, BFS 출처 : https://www.acmicpc.net/problem/19238 코드 & 풀이 import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;/** 1. 손님별 택시와 최단 거리 구하기 -> BFS* -> 거리별 > 행 번호 > 열 번호* 2. 나온 거리를 택시가 갈 수 있는지 확인* 가능 => 연료 계산* 불가능 => return -1* */public class 백준_스타트택시_19238 { static int N, M, fuel; static int[][] city; static Taxi taxi; static Map passe.. 2025. 5. 16.