(Here's my Journey) Beats 80%
Intuition\n Describe your first thoughts on how to solve this problem. \n\nThese kinds of problem are not very common , as normally the composer tries to make a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nThese kinds of problem are not very common , as normally the composer tries to make a problem interesting by mixing the use of differnt algorithm or making a different version of algorithm .\nBut in this question It was just constraints Hell.\n\nWhich took a hell lot of time to resolve.\n\nAnd one more thing it\'s not easy to calculate time complexity for such problems , I just gave it a go and thankfully it got accepted.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1. Just go through all possible which can start and also ent at 0 , but keep track of the visited node as they will be counted only once.\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```\nclass Solution {\npublic:\n    int ans;\n    vector<vector<pair<int , int>>> edges;\n    vector<int> vis;\n\n    int maximalPathQuality(vector<int>& values, vector<vector<int>>& edgess, int maxTime) {\n        \n        int n = values.size();\n        edges.resize(n);\n        vis.resize(n);\n\n        ans = 0;\n\n\n        for(auto vec : edgess) {\n            edges[vec[0]].push_back({vec[1] , vec[2]});\n            edges[vec[1]].push_back({vec[0] , vec[2]});\n        }\n        dfs(0 , 0 , values[0] , maxTime , values);\n\n        return ans;\n\n    }\n\n    void dfs(int node , int curr_time , int curr_sum , int mx_time , vector<int> &vals) {\n        \n        if(node == 0) {\n            ans = max(ans , curr_sum);\n        }\n\n        vis[node]++;\n\n        for(auto [next , time] : edges[node]) {\n            if(curr_time + time > mx_time) continue;\n            dfs(next , curr_time + time , curr_sum + (vis[next] ? 0 : vals[next]) , mx_time , vals);\n        }\n\n        vis[node]--;\n    }\n};\n```
['C++']