본문 바로가기

Java456

[프로그래머스/Java] 네트워크 -Codeimport java.util.*;class Solution { static boolean[] visited; public int solution(int n, int[][] computers) { int answer = 0; // visited visited = new boolean[n + 1]; // 리스트로 셋팅 ArrayList> nodes = new ArrayList(); for (int i = 0; i ()); // node 셋팅 for (int i = 0; i > nodes) { // 현재 노드 방문 처리 visited[now] = true;.. 2026. 1. 8.
[프로그래머스/Java] 완주하지 못한 선수 -Codeimport java.util.*;class Solution { public String solution(String[] participant, String[] completion) { Map completionMap = new HashMap(); for (String name : completion) { completionMap.put(name, completionMap.getOrDefault(name, 0) + 1); } for (String name : participant) { if (!completionMap.containsKey(name) || completionMa.. 2026. 1. 8.
[백준/Java] 27982번 큐브 더미 -Codeimport java.util.*;import java.io.*;public class BOJ27982 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int[].. 2026. 1. 8.
[백준/Java] 1463번 1로 만들기 -Codeimport java.util.Scanner;public class BOJ1463 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] dp = new int[n + 1]; for (int i = 2; i 직접 값을 몇개 넣어보니 다음과 같았습니다.- 1 ▶️ 1 - 2 ▶️ 1- 3 ▶️ 1 - 3 ▶️ 2 - 5 ▶️ 3 - 6 ▶️ 2 - 7 ▶️ 3 - 8 ▶️ 3 - 9 ▶️ 2 -10 ▶️ 3그래서 inde에 2와 3으로 뭔가 나눠야한다는 생각은 했지만 로직을 이상하게 짰습니다. 그래서 뭐가.. 2026. 1. 7.
[백준/Java] 1932번 정수 삼각형 -Codeimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.Arrays;import java.util.StringTokenizer;public class BOJ19323 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.r.. 2026. 1. 7.
[백준/Java] 9461번 파도반 수열 -Codeimport java.util.*;public class BOJ9461 { static long[] dp = new long[101]; static { for (int i = 1; i n이 100이 되면 9000억이 넘어버리는 것을 모르고 int로 배열을 선언해 틀렸습니다. 그래서 파이썬과 달리 long형으로 바꿔줘야 했습니다. 2026. 1. 7.