[C++] explained
First convert the edges vector to adjacency list.\nWe use a priority queue to store the cities we can visit and to extract the one with the lowest cost.\nAs we 
First convert the edges vector to adjacency list.\nWe use a priority queue to store the cities we can visit and to extract the one with the lowest cost.\nAs we extract a city from the priority queue, we check if it\'s the destination. If it\'s not, we add to the priority queue the adjacent cities.\nTo avoid making back and forward moves between two cities, we use a "seen" vector which stores the best time we have seen for that city.\nWhen we extract a city from the priority queue and we have seen it before with a better time, then we know the cost was also better (as it was extracted earlier), so we should not process it again.\n```\nclass Solution {\nprivate:\n    class City{\n    public:\n        int i;\n        int cost;\n        int time;\n        City(int i, int cost, int time):i(i), cost(cost), time(time){}\n    };\n    struct cityComparator{\n        bool operator()(City const& c1, City const& c2){\n            return c1.cost > c2.cost;\n        }\n    };\npublic:    \n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {\n        int n = passingFees.size();\n        priority_queue<City, vector<City>, cityComparator> cq;\n        cq.push(City(0, passingFees[0], 0));\n        vector<vector<pair<int, int>>> adj(n);\n        for (vector<int> &edge: edges){\n            adj[edge[0]].push_back(make_pair(edge[1], edge[2]));\n            adj[edge[1]].push_back(make_pair(edge[0], edge[2]));\n        }\n        vector<int> seen(n, maxTime + 1);\n        while (!cq.empty()){\n            City c = cq.top();\n            cq.pop();\n            if (seen[c.i] <= c.time)\n                continue;\n            seen[c.i] = c.time;\n            if (c.i == n - 1 && c.time <= maxTime)\n                return c.cost;\n            for (int i = 0; i < adj[c.i].size(); i++){\n                int ni = adj[c.i][i].first;\n                int nt = adj[c.i][i].second;\n                if (c.time + nt < seen[ni]){\n                    cq.push(City(ni, c.cost + passingFees[ni], c.time + nt));\n                }\n            }\n        }\n        return -1;\n    }\n};\n```\nm = max(n, edges.length)\nComplexity in worst case is O(m  * maxTime * log(m * maxTime)). Because every city could be the top of the priority queue at most maxTime times. Processing all the neighbours for all the n cities would be edges.length.\nHowever, in the average case it\'s much better.
['C', 'Heap (Priority Queue)']