Easiest C++ DP Solution : )
\nclass Solution {\npublic:\n    \n    int t[1001][1001];\n    \n    int Solve(vector<pair<int,int> > A[] , vector<int>&money , int node , int time , int Target
```\nclass Solution {\npublic:\n    \n    int t[1001][1001];\n    \n    int Solve(vector<pair<int,int> > A[] , vector<int>&money , int node , int time , int Target , int maxTime)\n    {\n\n        if(time>maxTime)\n            return 100000000;\n        \n        if(node==Target)\n        {\n            return money[Target] ;\n        }\n    \n        if(t[node][time]!=-1) return t[node][time] ; \n        \n        int Ans = 100000000 ;\n        for(auto child:A[node])\n        {\n            \n            if( time+child.second<=maxTime)\n                {   \n                    int temp = money[node]+Solve(A,money,child.first,time+child.second,Target,maxTime) ;\n                    \n                    Ans = min(Ans,temp) ;\n                }\n        }\n        \n        \n        \n        return t[node][time] =Ans; \n    }\n    \n    \n    \n    \n    \n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& A) {\n        int N = edges.size() ;\n        vector<pair<int,int>> V[N+1] ;\n        int n = -1;\n        for(auto x:edges){\n            V[x[0]].push_back({x[1],x[2]}) ;\n            V[x[1]].push_back({x[0],x[2]}) ;\n            n = max({n,x[0],x[1]});\n        }\n        \n        memset(t,-1,sizeof(t)) ;\n        \n        int Ans = Solve(V,A,0,0,n,maxTime) ;\n        \n        return (Ans<100000000)?Ans:-1 ;\n}\n};\n```
['Dynamic Programming']