반응형 탐색1 [코딩테스트] Java - 기본 점검: DFS/BFS 1. BFS더보기static int N = 5, M = 5;static int[][] map = new int[N][M];static boolean[][] visited = new boolean[N][M];static int[] dx = {-1, 1, 0, 0};static int[] dy = {0, 0, -1, 1};static void bfs(int x, int y) { Queue queue = new LinkedList(); queue.offer(new int[]{x, y}); visited[x][y] = true; while (!queue.isEmpty()) { int[] now = queue.poll(); int cx = now[0]; .. 2025. 4. 9. 이전 1 다음 반응형