본문 바로가기

BFS9

퍼즐 조각 채우기 - JAVA, BFS, 구현 https://school.programmers.co.kr/learn/courses/30/lessons/84021 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 import java.util.*;class Solution { static class Point { int x, y; Point (int x, int y) { this.x = x; this.y = y; } } static int n; static boolean[][] visited; public int solution(int[][] .. 2025. 6. 3.
아이템 줍기 - JAVA, BFS https://school.programmers.co.kr/learn/courses/30/lessons/87694 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 import java.util.*;class Solution { static final int SIZE = 102; static int[][] board = new int[SIZE][SIZE]; static boolean[][] visited = new boolean[SIZE][SIZE]; static int[] dx = {0, 0, 1, -1}; static int[] dy = {1, -1, 0, 0}; .. 2025. 6. 2.
단어 변환 - JAVA, BFS, Queue https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 코드 & 풀이 import java.util.*;class Solution { static class Word { String word; int count; Word (String word, int count) { this.word = word; this.count = count; } } public int solution(Strin.. 2025. 6. 1.
백준19238.스타트 택시 - JAVA, 구현, HashMap, List, BFS 출처 : https://www.acmicpc.net/problem/19238 코드 & 풀이 import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;/** 1. 손님별 택시와 최단 거리 구하기 -> BFS* -> 거리별 > 행 번호 > 열 번호* 2. 나온 거리를 택시가 갈 수 있는지 확인* 가능 => 연료 계산* 불가능 => return -1* */public class 백준_스타트택시_19238 { static int N, M, fuel; static int[][] city; static Taxi taxi; static Map passe.. 2025. 5. 16.
미로 탈출 - Python, BFS https://school.programmers.co.kr/learn/courses/30/lessons/159993 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr  코드 & 풀이 from collections import dequedef move_target(maps, directs, start_x, start_y, target): visited = [[0] * len(row) for row in maps] queue = deque() queue.append([start_x, start_y]) visited[start_x][start_y] = 1 while queue:.. 2024. 12. 29.
네트워크 - Python, DFS, BFS, Union_find https://school.programmers.co.kr/learn/courses/30/lessons/43162 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 풀이 - 나의 생각이게 왜 Lv.3일까?   코드def solution(n, computers): def dfs(node): visited[node] = True for neighbor, connected in enumerate(computers[node]): if connected and not visited[neighbor]: dfs(neighbor) visi.. 2024. 11. 21.