[JAVA] Modified DFS + visited
```\nclass Solution {\n    int maxq=0;\n    public void helper(List[] graph ,int  si,int ql,int vis[],int time,int []values){\n        if(time<0) return;\n     
```\nclass Solution {\n    int maxq=0;\n    public void helper(List<int[]>[] graph ,int  si,int ql,int vis[],int time,int []values){\n        if(time<0) return;\n         vis[si]++;\n        if(vis[si]==1) ql+=values[si];\n        \n        if(si==0 && time>=0) maxq=Math.max(maxq,ql);\n        \n       \n        \n        for(int []a:graph[si]){\n            int v=a[0];\n            int vtime=a[1];\n             \n            \n            helper(graph,v,ql,vis,time-vtime,values);\n        }\n        vis[si]--;\n    }\n    public int maximalPathQuality(int[] values, int[][] edges, int maxTime) {\n         int n=values.length;\n//        {node,time} for every node in the neighbor\n        List<int[]>[] graph=new ArrayList[n];\n         for(int i=0;i<n;i++){\n             graph[i]=new ArrayList<>();\n         }\n        \n        for(int a[]:edges){\n            int u=a[0];\n            int v=a[1];\n            int t=a[2];\n            \n            graph[u].add(new int[]{v,t});\n            graph[v].add(new int[]{u,t});\n        }\n        int vis[]=new int[n];\n        \n        helper(graph,0,0,vis,maxTime,values);\n        \n        return maxq;\n        \n    }\n}
['Backtracking', 'Java']