c++ dfs
\nclass Solution {\npublic:\n    int maximalPathQuality(vector<int>& values, vector<vector<int>>& edges, int maxTime) {\n        vector<vector<array<int, 2>>> g
```\nclass Solution {\npublic:\n    int maximalPathQuality(vector<int>& values, vector<vector<int>>& edges, int maxTime) {\n        vector<vector<array<int, 2>>> graph(values.size());\n        for (auto &e : edges) {\n            graph[e[0]].push_back({e[1], e[2]});\n            graph[e[1]].push_back({e[0], e[2]});\n        }\n\n        int res = values[0];\n        vector<int> seen(values.size());\n        function<void(int, int, int)> dfs = [&](int n, int v, int t) {\n            for (auto& [nxt, time] : graph[n]) {\n                if (t < time) {\n                    continue;\n                }\n\n                if (nxt == 0) {\n                    res = max(res, v);\n                }\n\n                int val = seen[nxt] ? 0 : values[nxt];\n                ++seen[nxt];\n                dfs(nxt, val + v, t - time);\n                --seen[nxt];\n            }\n        };\n        \n        seen[0] = 1;\n        dfs(0, values[0], maxTime);\n        seen[0] = 0;\n        return res;\n    }\n};\n```
[]