Very easy DFS code | Beginner friendly
\nclass Solution {\npublic:\n    int maxi=-1;\n    void solve(unordered_map<int,vector<pair<int,int>>> &m,vector<int> &temp, int node,int t,bool &f,vector<int>&
```\nclass Solution {\npublic:\n    int maxi=-1;\n    void solve(unordered_map<int,vector<pair<int,int>>> &m,vector<int> &temp, int node,int t,bool &f,vector<int>& v){\n        if(t<0) return;\n        if(node==0&&f&&t>=0){\n            int tp=0;\n            vector<int> vis(v.size(),0);\n            for(auto it: temp){\n                if(!vis[it]) {tp+=v[it];vis[it]=1;}\n            }\n            maxi=max(maxi,tp);\n        }\n        f=1;\n        for(auto i:m[node]){\n            temp.push_back(node);\n            solve(m,temp,i.first,t-i.second,f,v);\n            temp.pop_back();\n        }\n    }\n    int maximalPathQuality(vector<int>& v, vector<vector<int>>& e, int t) {\n        unordered_map<int,vector<pair<int,int>>> m;\n        for(auto i: e){\n            m[i[0]].push_back({i[1],i[2]});\n            m[i[1]].push_back({i[0],i[2]});\n        }\n        vector<int> temp;\n        bool f=0;\n        solve(m,temp,0,t,f,v);\n        if(maxi==-1) return v[0];\n        return maxi;\n    }\n};\n```
['Backtracking', 'Depth-First Search', 'Graph', 'Recursion', 'C']