[JavaScript] Simple DFS
javascript\nvar maximalPathQuality = function(values, edges, maxTime) {\n    const adjacencyList = values.map(() => []);\n    for (const [node1, node2, time] of
```javascript\nvar maximalPathQuality = function(values, edges, maxTime) {\n    const adjacencyList = values.map(() => []);\n    for (const [node1, node2, time] of edges) {\n        adjacencyList[node1].push([node2, time]);\n        adjacencyList[node2].push([node1, time]);\n    }\n    \n    const dfs = (node, quality, time, seen) => {\n        // if we returned back to the 0 node, then we log it as a valid value\n        let best = node === 0 ? quality : 0;\n        \n        // try to visit all the neighboring nodes within the maxTime\n        // given while recording the max\n        for (const [neighbor, routeTime] of adjacencyList[node]) {\n            const totalTime = time + routeTime;\n            if (totalTime > maxTime) continue;\n            if (seen.has(neighbor)) {\n                best = Math.max(best, \n                                dfs(neighbor, quality, totalTime, seen));\n            } else {\n                seen.add(neighbor);\n                best = Math.max(best, \n                                dfs(neighbor, quality + values[neighbor], totalTime, seen));\n                seen.delete(neighbor);\n            }\n        }\n        return best;\n    }\n    return dfs(0, values[0], 0, new Set([0]));\n};\n```\n
['Depth-First Search', 'JavaScript']