743. Network Delay Time

Sdílet
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

Komentáře • 15

  • @ashishkumaryadav5252
    @ashishkumaryadav5252 Před rokem +1

    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?

  • @_ROHITKUMAR-gh8ew
    @_ROHITKUMAR-gh8ew Před rokem +1

    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

  • @vikassharma-th7kn
    @vikassharma-th7kn Před rokem

    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

  • @utkarshsaxena7445
    @utkarshsaxena7445 Před 2 lety +1

    Can you give your roadmap link that's on github ?

  • @leepakshiyadav1643
    @leepakshiyadav1643 Před 2 lety +1

    Basically its the Dijkstra's algo, right?

  • @surajmisal3898
    @surajmisal3898 Před 2 lety +1

    Can you please try to upload it in 720p?

  • @pranavM40
    @pranavM40 Před 2 lety +1

    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.

    • @techadorabynivedita
      @techadorabynivedita  Před 2 lety +1

      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

    • @pranavM40
      @pranavM40 Před 2 lety

      @@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.

  • @cs51904
    @cs51904 Před 2 lety +1

    it is just a minimum spanning tree question😊😊😊

    • @techadorabynivedita
      @techadorabynivedita  Před 2 lety +1

      minimum spanning tree's algorihtm like prism and kruskal wont work for directed graph , you can you dijkstra algorithm to solve.

    • @techadorabynivedita
      @techadorabynivedita  Před 2 lety +1

      www.geeksforgeeks.org/why-prims-and-kruskals-mst-algorithm-fails-for-directed-graph/