weak testcase
[0,32,43,1000]\n[[0,1,10],[1,3,10],[2,3,35],[0,2,10]]\n 49\n \n [0,32,43,1000]\n[[0,2,10],[0,1,10],[1,3,10],[2,3,35]]\n 49\n \nit\'s giving wrong ans on my code
[0,32,43,1000]\n[[0,1,10],[1,3,10],[2,3,35],[0,2,10]]\n 49\n \n [0,32,43,1000]\n[[0,2,10],[0,1,10],[1,3,10],[2,3,35]]\n 49\n \nit\'s giving wrong ans on my code but still it passed internal testcase\n\n`\n     ArrayList<int[]> tree[];\n\t \n\t public int maximalPathQuality(int[] values, int[][] edges, int maxTime) {\n          int n=values.length;\n          tree=new ArrayList[n];\n          for (int i = 0; i <n; i++) {\n            tree[i]=new ArrayList<>();\n          }\n\n         for (int x[]:edges) {\n            tree[x[0]].add(new int[]{x[1],x[2]});\n            tree[x[1]].add(new int[]{x[0],x[2]});\n        }\n        int m[]=new int[n];\n         Queue<Node> q=new LinkedList<>();\n         q.add(new Node(0,0,values[0],new HashSet<>()));\n         int max=0;\n         while (!q.isEmpty()){\n             Node c=q.remove();\n             int time=c.time;\n             if(m[c.node]>c.val) continue;\n             m[c.node]=c.val;\n             if (c.node==0){\n                 max=Math.max(max,c.val);\n                \n             }\n\n             for (int x[]:tree[c.node]) {\n                 int newval=c.val;\n                 if (!c.vis.contains(x[0])){\n                    newval+=values[x[0]];\n                 }\n                 if (time+x[1]>maxTime) continue;\n\n                 q.add(new Node(\n                        x[0],time+x[1],newval,c.vis\n                ));\n             }\n         }\n         return max;\n    }\n    static class Node{\n        int node;\n        int time;\n        int val;\n\n        public Node(int node, int time, int val, HashSet<Integer> x) {\n            this.node = node;\n            this.time = time;\n            this.val = val;\n            vis.addAll(x);\n            vis.add(node);\n        }\n\n        HashSet<Integer> vis=new HashSet<>();\n\n    }\n\n`
[]