BFS1 743. Network Delay Time 743. Network Delay Time class Solution { private int[][] graph; private int[] visited; public int networkDelayTime(int[][] times, int n, int k) { this.makeGraph(times, n); this.visited = new int[n+1]; int answer = -1; Queue pq = new PriorityQueue(Comparator.comparingInt(p -> p[0])); pq.offer(new int[]{0, k}); while(!pq.isEmpty()) { var next = pq.poll(); if (visited[next[1]] != 0) continue; else .. 2023. 5. 15. 이전 1 다음