알고리즘 2 [Algorithm] BOJ 1158 import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Queue queue = new LinkedList(); StringBuffer sb = new StringBuffer(); int n = sc.nextInt(); int k = sc.nextInt(); for (int i = 1; i Algorithm 2021. 7. 28. [Algorithm] BOJ 1260 import java.util.*; public class Main { public static boolean[] dfsVisited; public static boolean[] bfsVisited; public static ArrayList graph = new ArrayList(); public static void dfs(int start) { dfsVisited[start] = true; System.out.print(start + " "); for (int i = 0; i < graph.get(start).size(); i++) { int x = graph.get(start).get(i); if (!dfsVisited[x]) dfs(x); } } public static void bfs(int .. Algorithm 2021. 7. 28. 이전 1 다음