본문 바로가기

Java458

[백준/Java] 2468번 안전 영역 -Codeimport java.io.*;import java.util.*;public class BOJ2468 { static boolean[][] visited; static class Pos { int row, col; public Pos(int row, int col) { this.row = row; this.col = col; } } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.i.. 2026. 1. 6.
[프로그래머스/Java] 피로도 -Codeimport java.util.*;class Solution { static boolean[] visited; static int answer = 0; public int solution(int k, int[][] dungeons) { visited = new boolean[dungeons.length]; DFS(0, k, dungeons); return answer; } private static void DFS(int depth, int now, int[][] dungeons) { // 최대 돌수 있는 던전의 수이므로 계속 검사 answer = Math.max(answer, depth); .. 2026. 1. 6.
[백준/Java] 16139번 인간-컴퓨터 상호작용 -Codeimport java.util.*;import java.io.*;public class BOJ16139 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); // 일수마다 알파벳의 누적합을 저장 int len = line.length(); int[][] alpaCntArr = new int[26][len + 1]; for (int i = 0; i 처음 .. 2026. 1. 6.
[백준/Java] 20949번 효정과 새 모니터 -Codeimport java.util.*;import java.io.*;public class BOJ20949 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); // ppi와 index를 저장 int[][] ppiAndIdxArray = new int[n][2]; for (int i = 0; i { if (o1[0] == .. 2026. 1. 6.
[백준/Java] 3060번 욕심쟁이 돼지 -Codeimport java.io.*;import java.util.*;public class BOJ3060 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testCase = Integer.parseInt(br.readLine()); for (int t = 0; t = sum) { sum *= 4; answer++; } System.out.p.. 2026. 1. 6.
[프로그래머스/Java] 소수 찾기 -Codeimport java.util.*;class Solution { static boolean[] visited; static Deque combi; static Set answer = new HashSet(); public int solution(String numbers) { int length = numbers.length(); visited = new boolean[length]; // 길이 1부터 최대 길이까지 탐색 for (int l = 1; l (); // dfs 시작 DFS(0, numbers, l, length); } // 중복없는 소수들의 갯수 반환 .. 2026. 1. 6.