C++  solution using Dijkstra's algorithm || commented
\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& e, vector<int>& fees) {\n        \n        //the number of nodes\n        int n=f
```\nclass Solution {\npublic:\n    int minCost(int maxTime, vector<vector<int>>& e, vector<int>& fees) {\n        \n        //the number of nodes\n        int n=fees.size();\n        \n        using pi=pair<int,pair<int,int>> ;\n        //min heap \n        //pq contains the format {cost,{time,node}} \n        priority_queue<pi,vector<pi>,greater<pi>> pq;\n        \n        \n        //create a adjacency list\n        vector<vector<pair<int,int>>> adj(fees.size());\n        \n        for(int i=0;i<e.size();i++)\n        {\n            adj[e[i][0]].push_back({e[i][1],e[i][2]});\n            adj[e[i][1]].push_back({e[i][0],e[i][2]});\n        }\n        \n        \n        vector<int> cost(n,INT_MAX);\n        vector<int> time(n,INT_MAX);\n        cost[0]=fees[0];\n        time[0]=0;\n        \n        pq.push({cost[0],{time[0],0}});\n        while(!pq.empty())\n        {\n            auto [currCost,v]=pq.top();\n            auto [currMin,node]=v;\n            pq.pop();\n            for(auto [x,t] :  adj[node])\n            {\n                \n                //if you can reach the city in <=maxTime\n                if(currMin + t <= maxTime)\n                {\n                    //check if the cost can be decreased\n                    if(cost[x] > currCost+fees[x])\n                    {\n                        cost[x]=currCost+fees[x];\n                        \n                        time[x] = currMin + t;\n                        //push it into pq\n                        pq.push({cost[x],{time[x],x}});\n                    }\n                    \n                    //if the cost of the current node cannot be decreased then check\n                    //if we can decrease the time of the node\n                    else if(time[x] > currMin+t)\n                    {\n                        //update the time\n                        time[x]=currMin+t;\n                        //push it into pq\n                        pq.push({currCost+fees[x],{time[x],x}});\n                        \n                    }\n                }\n            }\n        }\n        return cost[n-1]==INT_MAX ? -1 : cost[n-1];\n    }\n};\n```\n**Upvote if this helps you :)**
['C']