djikstra
-
dijkstra_Leetcode_743. Network Delay Time [swift]알고리즘/알고리즘 문제풀이 2025. 2. 19. 17:51
https://leetcode.com/problems/network-delay-time/description/ 문제접근그냥 다익스트라.하지만 꾸준히 복습하자 정답코드더보기더보기class Solution { func networkDelayTime(_ times: [[Int]], _ n: Int, _ k: Int) -> Int { var distance = [Int](repeating: Int.max, count: n) var graph: [Int: [(Int, Int)]] = [:] var queue: [(Int, Int)] = [] times.forEach { values in let source = values[0] ..