본문 바로가기

분류 전체보기122

[알고리즘] BFS - 큐, 최단거리 1. Queue 사용 import org.springframework.boot.autoconfigure.SpringBootApplication; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; @SpringBootApplication public class Main { static final int Max_N = 10; static int N, E; static int[][] Graph = new int [Max_N][Max_N]; /.. 2023. 11. 29.
[프로그래머스 연습문제 level_3 ] 네트워크 처음 생각 무조건 dfs 다. 내가 푼 방법 class Solution { static int[] visited; static int N = 0; static int[][] Computers; public int solution(int n, int[][] computers) { int answer = 0; visited = new int[n]; Computers = computers; N = n; for(int i=0; i 2023. 11. 16.
[백준 풀이_Java] 9012 괄호 (실버4) 처음 생각 문제를 딱 보자마자 스택을 써야겠다고 생각했다. 내가 푼 방법 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int s = Integer.parseInt(br.readLine()); String strTmp; Stack stack; for (int i = 0; i.. 2023. 11. 13.
[알고리즘] DFS - 재귀호출, 스택(Stack) 1. 재귀호출 사용 import java.util.*; public class Main { static final int Max_N = 10; static int N, E; static int[][] Graph = new int [Max_N][Max_N]; // 노드,간선 정보를 이중배열에 담아둠 static boolean[] Visited = new boolean[Max_N]; // 노드 방문 여부를 확인하기위함 public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLi.. 2023. 11. 3.
[Sofreer 문제풀이] Lv.2(성적 평균) feat. Java 1. 성적 평균 import java.io.*; import java.util.*; public class Main { 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 K = Integer.parseInt(st.nextToken()); int[] arrScore = new int[N]; String[] tmp = br.readLine(.. 2023. 11. 3.
[Sofreer 문제풀이] Lv.2(GBC) feat. Java 1. GBC import java.io.*; import java.util.*; public class Main { 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[][] standard = new int[N][N]; int[][] test =new int[M][.. 2023. 11. 3.