[C++] 3 Solutions ( BFS, Dijkstra, Bellman-Ford )
BFS \nTC = 108ms\n\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<pair<int,int>> adj[n+1];\n  
**BFS** \n*TC = 108ms*\n```\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<pair<int,int>> adj[n+1];\n        for(int i=0;i<times.size();i++)\n                adj[times[i][0]].push_back({times[i][1],times[i][2]});\n        vector<int> dist(n+1,INT_MAX);\n        queue<int> q;\n        q.push(k);\n        dist[k]=0;\n        while(!q.empty())\n        {\n            int t=q.front();\n            q.pop();\n            for(pair<int,int> it:adj[t])\n            {\n                if(dist[it.first]>dist[t]+it.second)\n                {\n                    dist[it.first]=dist[t]+it.second;\n                    q.push(it.first);\n                }\n            }\n        }\n        int res=0;\n        for(int i=1;i<=n;i++)\n        {\n            if(dist[i]==INT_MAX)\n                return -1;\n            res=max(res,dist[i]);\n        }\n        return res;\n    }\n};\n```\n\n**Dijkstra Algorithm**\n*TC = 112ms*\n```\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<pair<int,int>> adj[n+1];\n        for(int i=0;i<times.size();i++)\n                adj[times[i][0]].push_back({times[i][1],times[i][2]});\n        vector<int> dist(n+1,INT_MAX);\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;\n        pq.push({0,k});\n        dist[k]=0;\n        while(!pq.empty())\n        {\n            pair<int,int> t=pq.top();\n            pq.pop();\n            for(pair<int,int> it:adj[t.second])\n            {\n                if(dist[it.first]>t.first+it.second)\n                {\n                    dist[it.first]=t.first+it.second;\n                    pq.push({dist[it.first],it.first});\n                }\n            }\n        }\n        int res=0;\n        for(int i=1;i<=n;i++)\n        {\n            if(dist[i]==INT_MAX)\n                return -1;\n            res=max(res,dist[i]);\n        }\n\t\treturn res;\n\t}\n};\n   ```\n   \n   **Bellman-Ford Algorithm**\n   *TC = 208ms*\n   ```\n   class Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n        vector<int> dist(n+1,INT_MAX);\n        dist[k]=0;\n        \n        for(int i=0;i<n-1;i++)\n        {\n            bool flag=false;\n            for(auto node:times)\n            {\n                int src=node[0];\n                int des=node[1];\n                int time=node[2];\n                if(dist[src]!=INT_MAX&&dist[des]>dist[src]+time)\n                {\n                    dist[des]=dist[src]+time;\n                    flag=true;\n                }\n            }\n            if(flag==false)\n                break;\n        }\n        int res=0;\n        for(int i=1;i<=n;i++)\n        {\n            if(dist[i]==INT_MAX)\n                return -1;\n            res=max(res,dist[i]);\n        }\n        return res;\n    }\n};\n```\n\n*Do upvote if you find it useful!!!*\n
['Breadth-First Search', 'C', 'C++']