Bellman Ford and Dijkstra / short and Easy to understand
** Bellmann ford\n\n \nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n       int n = times.size();\n\t\t\tif (
** Bellmann ford**\n```\n \nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n       int n = times.size();\n\t\t\tif (!n) return 0;\n\t\t\t\n\t\t\tvector<int>dist(N+1, INT_MAX);\n\t\t\tint res = 0;\n\t\t\t\n\t\t\tdist[K] = 0;\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\tint u = times[j][0];\n\t\t\t\t\tint v = times[j][1];\n\t\t\t\t\tint w = times[j][2];\n\t\t\t\t\tif (dist[u] != INT_MAX && dist[u] + w < dist[v])\n\t\t\t\t\t\tdist[v] = w + dist[u];\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 1; i <= N; i++)\n\t\t\t\tres = max(res, dist[i]);\n\n\t\t\treturn res == INT_MAX ? -1 : res;\n\t\t}\n};\n```\n**  Dijkstra**\n```\nclass Solution {\n\tpublic:\n\t\tint networkDelayTime(vector<vector<int>>& times, int N, int K) {\n\t\t\t\n\t\t\tpriority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;\n\t\t\tvector<int>dist(N+1, INT_MAX);\n\t\t\t\n\t\t\tpq.push({0, K});\n\t\t\tdist[K] = 0;\n\t\t\t\n\t\t\tunordered_map<int, vector<pair<int, int>>>adj;\n\t\t\tfor (auto i:times)\n\t\t\t\tadj[i[0]].push_back({i[1],i[2]});\n\t\t\t\n\t\t\twhile (!pq.empty()) {\n\t\t\t\tauto p = pq.top();\n\t\t\t\tpq.pop();\n\t\t\t\t\n\t\t\t\tint u = p.second;\n\t\t\t\tfor (auto i:adj[u]) {\n\t\t\t\t\tint v = i.first;\n\t\t\t\t\tint w = i.second;\n\t\t\t\t\t\n\t\t\t\t\tif (dist[v] > dist[u] + w) {\n\t\t\t\t\t\tdist[v] = dist[u] + w;\n\t\t\t\t\t\tpq.push({dist[v], v});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tint res = 0;\n\t\t\tfor (int i = 1; i <= N; i++)\n\t\t\t\tres = max(res, dist[i]);\n\t\t\t\n\t\t\treturn res == INT_MAX ? -1 : res;\n\t\t}\n\t};\n\t```
['C']