classSolution{publicint[]gardenNoAdj(int N,int[][] paths){
HashMap<Integer,ArrayList<Integer>>map=newHashMap<>();for(int i=0;i<=N;i++){
map.put(i,newArrayList<Integer>());}for(int i =0;i<paths.length;i++){int a =paths[i][0];int b=paths[i][1];
map.get(a).add(b);
map.get(b).add(a);}//// just check the correction of the Building Graph // for(int i=0;i<=N;i++){// System.out.println(map.get(i));// }int[] re=newint[N];//从任意一个节点开始循环,for(int i =1;i<=N;i++){boolean[] used=newboolean[5];//adj
ArrayList<Integer> adj=map.get(i);for(int j=0;j<adj.size();j++){
used[re[adj.get(j)-1]]=true;//re的错位。为了避免错误可以把re放在后面转}for(int j=1;j<5;j++){if(used[j]==false){re[i-1]=j;break;}}}return re;}}