C++ Memoization solution
\nclass Solution {\npublic:\n    int n;\n    int helper(int v,int time ,vector<unordered_map<int,int>> &graph ,vector<vector<int>>&dp , vector<int>& fees ){\n  
```\nclass Solution {\npublic:\n    int n;\n    int helper(int v,int time ,vector<unordered_map<int,int>> &graph ,vector<vector<int>>&dp , vector<int>& fees ){\n        if(v == n-1)\n               return fees[n-1];\n        if(dp[v][time]!=-1)\n            return dp[v][time];\n        int ans = INT_MAX;\n        for(auto &g: graph[v]){\n            if(time-g.second>=0){\n                int cost = helper(g.first,time-g.second, graph,dp,fees);\n                ans = min(ans,cost);\n            }\n        }\n        return dp[v][time] = ans!=INT_MAX ? ans + fees[v] : INT_MAX;\n    }\n    \n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        n = passingFees.size(); //no of vertices\n        vector<vector<int>> dp(n, vector<int>(maxTime+1 , -1));\n        //you have to go from 0 to n-1 within maxTime by spending the minimum amount of money. \n        \n        vector<unordered_map<int,int>> graph(n);\n        //Important point is to note that there may be multiple roads of differing travel times connecting the same two cities. So take the route with the minimum cost. \n        for(auto & e: edges){\n            if( graph[e[0]][e[1]]==0)\n                graph[e[0]][e[1]] = e[2];\n            else \n                 graph[e[0]][e[1]] = min( graph[e[0]][e[1]] , e[2]);\n            \n            if(graph[e[1]][e[0]] == 0)                \n                graph[e[1]][e[0]] = e[2];\n            else \n                graph[e[1]][e[0]] = min(graph[e[1]][e[0]] , e[2]);\n        }\n        int ans =  helper(0,maxTime,graph,dp,passingFees);                    \n        return ans==INT_MAX ? -1 : ans;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']