743. Network Delay Time
Vložit
- čas přidán 12. 05. 2022
- PROBLEM LINK : leetcode.com/problems/network...
SOLUTION LINK : github.com/niveditaprity/Leet...
Connect With Me:
linkedin : / nivedita-kumari-47a469163
Telegram link: t.me/tech_adora
Twitter link : / nivedit08422106
Instagram link : / tech_adora
#dsa #Network Delay Time #placements
#LeetCode #Leetcode743 #DataStructures
#LinkedList #Interview_Preparation #DSA #Interview #Practice #gfg #Leetcode #Medium #LinkedList #Algorithm #DataStructure #CPP #Preparation #NG #nickode #CookCodeTravel #CCT #programmer #Mayleetcodechallenge #datastructures #challenge #Codenewbie #leetcode #leetcodechallenge #1679leetcode #dailychallenge #leetcodesolution
mam, in normal Dijakstra's algo we use priority queue but here you have used a simple queue, is there any benefit in doing so in terms of time complexity or you used it just for the sake of simplicity?
why we can not do it by topological sort?
class Solution {
private:
void dfs(int src, vector& vis, vector adj[], stack& st) {
vis[src] = 1;
for (auto it : adj[src]) {
int v = it.first;
if (!vis[v]) {
dfs(v, vis, adj, st);
}
}
st.push(src);
}
public:
int networkDelayTime(vector& times, int n, int k) {
vector adj[n + 1];
for (int i = 0; i < times.size(); i++) {
int u = times[i][0];
int v = times[i][1];
int wt = times[i][2];
adj[u].push_back({ v, wt });
}
stack st;
vector vis(n + 1, 0);
// applying topo sort using dfs
for (int i = 1; i
Guys despite this has complexity of Vsquare, it is commonly accepted in interviews because the interviewer wants to see how we solve problems
The most optimised solution would be solved in ElogV
Can you give your roadmap link that's on github ?
given in description and repo -DSA-Bootcamp
Basically its the Dijkstra's algo, right?
you can solve it with Dijkstra , I used here BFS
Can you please try to upload it in 720p?
It is Processing in HD, after sometime you can see it
Hii! Nivedita I want to do competitive programming and DSA but I understand their questions but I don't know how to do program on any platform please guide me how to solve. I am following your all daily video and try to with own but I am unable to solve the daily program.
if you are a beginner then start with easy algorihthm like two pointer ,prefix sum etc. start solving easy problems first on the topic that you have learnt .
we are getting dp and graph problems these weeks and it is advance dsa. you can follow the roadmap of codechef otherwise my dsa roadmap on github
@@techadorabynivedita Thank you so much and If you provide me github link for roadmap of DSA and I will try my best and if any doubt I will message you.
it is just a minimum spanning tree question😊😊😊
minimum spanning tree's algorihtm like prism and kruskal wont work for directed graph , you can you dijkstra algorithm to solve.
www.geeksforgeeks.org/why-prims-and-kruskals-mst-algorithm-fails-for-directed-graph/