Easy Java Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n\nclass Solution {\n    Map<Integer, Map<Integer, Integer> > g = new HashMap();\n    int res = 0;\n    int[] values;\n    public int maximalPathQuality(int[] values, int[][] edges, int maxTime) {\n        this.values = values;\n        for(int[] e : edges) {\n            int u = e[0], v = e[1], t = e[2];\n            g.computeIfAbsent(u, x -> new HashMap()).put(v, t);\n            g.computeIfAbsent(v, x -> new HashMap()).put(u, t);\n        }\n        dfs(new ArrayList(), 0, maxTime, 0);\n        return res;\n    }\n    void dfs(List<Integer> path, int cur, int maxTime, int time) {\n        path.add(cur);\n        if(cur == 0) {\n            int tmp = 0;\n            Set<Integer> hs = new HashSet();\n            for(int i : path) {\n                if(hs.add(i)) tmp += values[i];\n            }\n            res = Math.max(res, tmp);\n        }\n        for(var en : g.getOrDefault(cur, new HashMap<>()).entrySet()) {\n            int nei = en.getKey(), t = en.getValue();\n            if(t + time > maxTime) continue;\n            dfs(path, nei, maxTime, t + time);\n        }\n        path.remove(path.size() - 1);\n    }\n}\n```
['Java']