10. Most people do this by DFS only | BFS DFS-C++,JAVA | LeetCode 547-No of Provinces with Intuition

Поділитися
Вставка
  • Опубліковано 28 чер 2024
  • If you appreciate the hard work or want to be consistent with the bootcamp, Please 𝐬𝐮𝐛𝐬𝐜𝐫𝐢𝐛𝐞 here - / @keertipurswani
    𝐂𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐝𝐞𝐭𝐚𝐢𝐥𝐬 𝐚𝐧𝐝 𝐞𝐧𝐫𝐨𝐥𝐥 𝐟𝐨𝐫 𝐨𝐮𝐫 𝐋𝐈𝐕𝐄 𝐜𝐨𝐮𝐫𝐬𝐞𝐬 𝐡𝐞𝐫𝐞-
    www.educosys.com
    You can also connect with me on-
    𝐋𝐢𝐧𝐤𝐞𝐝𝐈𝐧 - / keertipurswani
    𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 (for personal, raw and real side of my life) - keerti.purs...
    You can follow The Literate Store here-
    𝐋𝐢𝐧𝐤𝐞𝐝𝐈𝐧 - / 96590309
    𝐈𝐧𝐬𝐭𝐚𝐠𝐫𝐚𝐦 - / theliteratestore
    The video contains following parts-
    0:00-2:05 - Introduction and reminder to be consistent
    2:05-8:20 - Question Explanation and Intuition
    8:20-15:20 - DFS CPP Code in detail
    15:20-22:20 - DFS JAVA Code in detail
    BFS CPP Code in detail
    22:20- BFS JAVA Code in detail
    #graphs #dsa #software developer #dsalgo

КОМЕНТАРІ • 15

  • @rajendiranvenkat5992
    @rajendiranvenkat5992 4 місяці тому

    Thank god. Video came.

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 4 місяці тому

    Good explanation 👏 🎉

  • @harshav4704
    @harshav4704 4 місяці тому

    Mam this is really a good and simple one and i was able to do following your dfs lecture logic. Thanks keerti mam.😀👍🏻

  • @Aarya985
    @Aarya985 4 місяці тому

    Thanks ma'am

  • @Raj10185
    @Raj10185 4 місяці тому

    Awsome video mam, I finally did the bfs code for this problem

  • @bluebirdclub092
    @bluebirdclub092 4 місяці тому

    thnx
    😇

  • @sharatpaul
    @sharatpaul 4 місяці тому +1

    Please use white pen instead of red since the background is black

  • @sudiptosaha7467
    @sudiptosaha7467 Місяць тому

    Can be done using BFS. I tried this way -
    int NumProvinces(vector & adjMat)
    {
    q.push(0);
    for (int j = 0; j < numNodes; j++)
    {
    if (!visited[j]) {
    while (!q.empty())
    {
    int curr = q.front();
    q.pop();
    for (int i = 0; i < numNodes; i++)
    {
    if (adjMat[curr][i] && !visited[i])
    {
    q.push(i);
    visited[i] = true;
    }
    }
    }
    numProvince++;
    }
    }
    return numProvince;
    }

  • @nithiin7
    @nithiin7 4 місяці тому

    Teach us problems which are application of graph that can't be identified on first sight that is an application of graph

    • @KeertiPurswani
      @KeertiPurswani  4 місяці тому

      Yup! Will teach everything! Be patient! Hope you watched the last video! That was one such question!

  • @shwetabansal2202
    @shwetabansal2202 4 місяці тому

    Do you have any upcoming series on string/trie related questions ?

  • @avinashtiwari4025
    @avinashtiwari4025 9 днів тому

    is time complexity of dfs is o(n2)?