DFS || BACKTRACKING || C++ || EASY TO UNDERSTAND 60% FASTER SOLUTION
\nclass Solution {\npublic:\n    int maximalPathQuality(vector<int>& values, vector<vector<int>>& edges, int maxTime) {\n        int n = values.size();\n       
```\nclass Solution {\npublic:\n    int maximalPathQuality(vector<int>& values, vector<vector<int>>& edges, int maxTime) {\n        int n = values.size();\n        int res = values[0];\n        vector<vector<pair<int,int>>> graph(n);\n        for(int i=0;i<edges.size();i++)\n        {\n            graph[edges[i][0]].push_back({edges[i][1], edges[i][2]});\n            graph[edges[i][1]].push_back({edges[i][0], edges[i][2]});\n        }\n        \n        vector<int> visited(n, 0);\n        dfs(graph, values, visited, res, 0, 0, 0, maxTime);\n        return res;\n    }\n    \n    void dfs(vector<vector<pair<int,int>>>& graph, vector<int>& values, vector<int>& visited, int& res, int node, int score, int time, int& maxTime)\n    {\n        if(time > maxTime)\n            return;\n        \n        if(visited[node] == 0)\n            score += values[node];\n        \n        visited[node]++;\n\t\t\n      \n        if(node == 0)\n            res = max(res, score);\n        \n        for(auto it : graph[node])\n        {\n            int neigh = it.first;\n            int newTime = time + it.second;\n            dfs(graph, values, visited, res, neigh, score, newTime, maxTime);\n        }\n        \n        visited[node]--;\n    }\n};\n```
['Backtracking', 'Depth-First Search', 'Graph', 'C', 'C++']