[C++] Djikstra's Algorithm (Very Easy To Understand) (Beats 85%)
\n    // Using Priority queue (Min-heap)\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n        vector<pair<int,int>> g[N+1];\n        f
```\n    // Using Priority queue (Min-heap)\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n        vector<pair<int,int>> g[N+1];\n        for(int i=0;i<times.size();i++)\n            g[times[i][0]].push_back(make_pair(times[i][1],times[i][2]));\n        vector<int> dist(N+1, 1e9);\n        dist[K] = 0;\n        priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int>>> q;\n        q.push(make_pair(0,K));\n        pair<int,int> temp;\n        bool visit[N+1];\n        memset(visit, false, sizeof(visit));\n        while(!q.empty()){\n            temp = q.top();\n            q.pop();\n            int u = temp.second;\n            visit[u] = true;\n            for(int i=0;i<g[u].size();i++){\n                int v = g[u][i].first;\n                int weight = g[u][i].second;\n                if(visit[v]==false && dist[v] > dist[u] + weight){\n                    dist[v] = dist[u] + weight;\n                    q.push(make_pair(dist[v], v));\n                }\n            }\n        }\n        int ans = 0;\n        for(int i=1;i<dist.size();i++){\n            ans = max(ans, dist[i]);\n        }\n        if(ans==1e9) return -1;\n        return ans;\n    }\n```\nFeel free to ask any doubts in the **comment** section.\nIf you like this solution, do **UPVOTE**.\nHappy Coding :)
['C', 'Heap (Priority Queue)', 'C++']