C++ using DP
\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& fees) {\n        \n        int n=fees.size();\n        vector
```\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& fees) {\n        \n        int n=fees.size();\n        vector<vector<pair<int,int>>> graph(n);\n        \n        for(int i=0;i<edges.size();i++){\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<vector<int>> dp(maxTime+1,vector<int>(n,INT_MAX));\n        dp[0][0]=fees[0];\n        \n        for(int i=0;i<=maxTime;i++){\n            for(int j=0;j<n;j++){\n                int currFees=dp[i][j];\n                if(currFees==INT_MAX){\n                    continue;\n                }\n                for(auto node:graph[j]){\n                    int next=node.first;\n                    int time=i+node.second;\n                    if(time<=maxTime){\n                        dp[time][next]=min(dp[time][next],fees[next]+currFees);\n                    }\n                }\n            }\n        }\n        \n        int ans=INT_MAX;\n        for(int t=0;t<=maxTime;t++){\n            ans=min(ans,dp[t][n-1]);\n        }\n        if(ans==INT_MAX){\n            return -1;\n        }\n        return ans;\n    }\n};\n```
[]