Javascript Solution using Djikstra's
There\'s two key points to solving this problem. \n\nFirstly you need a way to ensure you only add to the queue when it will either be a benefit to cost or time
There\'s two key points to solving this problem. \n\nFirstly you need a way to ensure you only add to the queue when it will either be a benefit to cost or time. And the 2nd thing to note is that there could be more than one edge with a different time factor so you should only try to  store the best time for each edge.\n\nWith that in mind the solution below is an application of Djikstra\'s algorithm to solve for best cost vs a limit on max time.\n\n```\nvar minCost = function (maxTime, edges, passingFees) {\n    const n = passingFees.length;\n    const graph = new Array(n);\n\n    for (let i = 0; i < edges.length; ++i) {\n        const [from, to, time] = edges[i];\n\n        graph[from] = graph[from] || [];\n        graph[from][to] = Math.min(graph[from][to] ?? Infinity, time);\n\n        graph[to] = graph[to] || [];\n        graph[to][from] = Math.min(graph[to][from] ?? Infinity, time);\n    }\n\n    const q = new MinPriorityQueue();\n    q.enqueue([0, 0], passingFees[0]);\n\n    const bestTimes = new Array(n).fill(Infinity);\n\n    while (q.size()) {\n        const { element, priority } = q.dequeue();\n        const [currNode, currTime] = element;\n        \n        if (currNode === n - 1) {\n            return priority;\n        }\n\n        for (const node in graph[currNode]) {\n            const nextNode = parseInt(node);\n            const nextTime = graph[currNode][node] + currTime;\n\n            if (nextTime <= maxTime && nextTime < bestTimes[nextNode]) {\n                bestTimes[nextNode] = nextTime;\n                q.enqueue([nextNode, nextTime], passingFees[nextNode] + priority);\n            }\n        }\n    }\n    return -1;\n};\n```\n\nEdited thanks to @da5idf
['JavaScript']