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
Thank god. Video came.
Good explanation 👏 🎉
Mam this is really a good and simple one and i was able to do following your dfs lecture logic. Thanks keerti mam.😀👍🏻
Thanks ma'am
Awsome video mam, I finally did the bfs code for this problem
thnx
😇
Please use white pen instead of red since the background is black
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;
}
isme naya kaya hai
Teach us problems which are application of graph that can't be identified on first sight that is an application of graph
Yup! Will teach everything! Be patient! Hope you watched the last video! That was one such question!
Do you have any upcoming series on string/trie related questions ?
is time complexity of dfs is o(n2)?
yes, O(n^2)