29 lines
888 B
Java
29 lines
888 B
Java
package com.hong.www;
|
|
|
|
import java.util.*;;
|
|
|
|
public class A734 {
|
|
public int networkDelayTime(int[][] times, int n, int k) {
|
|
HashMap<Integer,ArrayList<int[]>> time=new HashMap<>();
|
|
for(int[]x:times){
|
|
if(time.containsKey(x[0])){
|
|
ArrayList<int[]> temp=time.get(x[0]);
|
|
temp.add(new int[]{x[1],x[2]});
|
|
}else{
|
|
time.put(x[0],new ArrayList<int[]>(){{add(new int[]{x[1],x[2]});}});
|
|
}
|
|
if(time.containsKey(x[1])){
|
|
ArrayList<int[]> temp=time.get(x[1]);
|
|
temp.add(new int[]{x[0],x[2]});
|
|
}else{
|
|
time.put(x[1],new ArrayList<int[]>(){{add(new int[]{x[0],x[2]});}});
|
|
}
|
|
}
|
|
int[] list=new int[n+1];
|
|
for(int i=1;i<=n;i++){
|
|
list[i]=Integer.MAX_VALUE;
|
|
}
|
|
return 0;
|
|
}
|
|
}
|