The idea is to find the time to reach every other node from given node K

Then, to check if all nodes can be reached and if it can be reached then return the time taken to reach the farthest node (node which take longest to get the signal).

As the signal traverses concurrently to all nodes, we have to find the maximum time it takes to reach a node among all nodes from given node K.

If any single node takes Integer.MAX_Value, then return -1, as not all nodes can be reached

add the index of all the nodes which can be reached from a node to a list and store this list in a hashmap

then its similar to dijkstra's shortest path algorithm except that I am not using Priority Queue to get the minimum distance node. See comments.

```
class Solution {
public int networkDelayTime(int[][] times, int N, int K) {
int r = times.length, max = Integer.MAX_VALUE;
Map<Integer,List<Integer>> map = new HashMap<>();
for(int i=0;i<r;i++){
int[] nums = times[i];
int u = nums[0];
int v = nums[1];
List<Integer> list = map.getOrDefault(u,new ArrayList<>());
list.add(i);
map.put(u,list);
}
if(map.get(K) == null){
return -1;// no immediate neighbor of node K, so return -1
}
int[] dist = new int[N+1];//dist[i] is the time taken to reach node i from node k
Arrays.fill(dist,max);
dist[K] = 0;
Queue<Integer> queue = new LinkedList<>();
queue.add(K);
while(!queue.isEmpty()){
int u = queue.poll();
int t = dist[u];
List<Integer> list = map.get(u);// get the indices of all the neighbors of node u
if(list == null)
continue;
for(int n:list){
int v = times[n][1];
int time = times[n][2];// time taken to reach from u to v
if(dist[v] > t + time){// if time taken to reach v from k is greater than time taken to reach from k to u + time taken to reach from u to v, then update dist[v]
dist[v] = t + time;
queue.add(v);// as we have found shorter distance to node v, explore all neighbors of v
}
}
}
int res = -1;
for(int i=1;i<=N;i++){
int d = dist[i];
if(d == max){// if d is max, it means node i can not be reached from K, so return -1
return -1;
}
res = d > res ? d : res;
}
return res;
}
}
```

Note: I have updated the solution description and solution. Yes, my solution is not exactly dijkstra, but it was inspired by it and I thought it was very similar except that it is not very similar.