Simple Dijstra algorithm with explanation | CPP
```\n//Basically the problem is Single source shortest path problem with time constraint.\n\n// DIJSTRA ALGO\n//PLEASE GUYZ UPVOTE IT!!! THANK YOU\n\n\n\n\n\n#d
```\n//Basically the problem is Single source shortest path problem with time constraint.\n\n// DIJSTRA ALGO\n//PLEASE GUYZ UPVOTE IT!!! THANK YOU\n\n\n\n\n\n#define pr pair<int, pair<int, int>>\n#define ll long long int\n\nclass Solution {\npublic:\n\n    \n    int minCost(int maxTime, vector<vector<int>>& ed, vector<int>& pass) {\n        int n = pass.size();\n        vector<pair<int, int>> adj[n];\n        \n        //making a graph\n        for(vector<int> e: ed) {\n            adj[e[0]].push_back({e[1], e[2]});\n            adj[e[1]].push_back({e[0], e[2]});\n        }\n        \n        //taking min priority queue as {cost, vertex, time} \n        priority_queue<pr, vector<pr>, greater<pr>> pq;\n        //Initial vertex\n        pq.push({pass[0], {0, 0}});\n        \n        //map to track of vertex which is visited with minimum time\n        //It maps vertex and minimum time to reach that vertex\n        unordered_map<int, int> vis;\n        \n        \n        //Simple Dijstra algorithm\n        while(!pq.empty()) {\n            pr crr = pq.top(); pq.pop();\n            int curr = crr.second.first, time = crr.second.second, cost = crr.first;\n            \n            //Destination\n            if(curr == n-1) return cost;\n            \n            //Visited with current time\n            vis[curr] = time;\n            \n            for(pair<int, int> p: adj[curr]) {\n                int ad = p.first, ctime = p.second;\n                int ttime = time + ctime;\n                \n                //if vertex is not visited or vertex is visited prior but with more time, we push it into queue else continue\n                if(vis.find(ad) != vis.end() && vis[ad] <= ttime) continue;\n                vis[ad] = ttime;\n                //check if total time is less or equal to maxTime\n                if(ttime <= maxTime) pq.push({cost + pass[ad], {ad, ttime}});\n            }\n            \n        }\n        \n        //Not possible\n        return -1;\n        \n        //If you understood please upvote!!!\n    }\n};\n
['Graph', 'C', 'Heap (Priority Queue)', 'C++']