Divide Nodes Into the Maximum Number of Groups | Leetcode 2493
HTML-код
- Опубликовано: 8 фев 2025
- This video explains Divide Nodes Into the Maximum Number of Groups problem using the most optimal bipartite graph solution using BFS.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
🟣 JOIN our 𝐋𝐈𝐕𝐄 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐭𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐩𝐫𝐨𝐠𝐫𝐚𝐦 through whatsapp query: +91 8918633037
🟣 𝐂𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐚𝐥𝐥 𝐨𝐮𝐫 𝐂𝐨𝐮𝐫𝐬𝐞𝐬: techdose.co.in/
🔵 LinkedIn: / surya-pratap-kahar
🔴 INSTAGRAM: / techdose_official
🟢 𝐓𝐞𝐜𝐡𝐝𝐨𝐬𝐞-𝟏𝟎𝟎 𝐬𝐡𝐞𝐞𝐭: docs.google.co...
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Possible Bipartition: • Possible Bipartition |...
𝐂𝐎𝐃𝐄 𝐋𝐈𝐍𝐊: gist.github.co...
I initially went through Neetcode's solution, I thought I understood everything he was explaining, but end of the video, I was stuck not knowing where to begin. Now after going through your video solution, you make it easy to understand what to exactly do for a problem step by step and I am even confident enough to even teach someone else how to solve this problem. Just brilliant, how you break down a complex problem into smaller sub-problem and explain it in detail. Thank you for this!
welcome :)
Putting some effort before actually explaining
coming up with such logic is genius. By just seeing HARD written beside the question i feel like quitting
Keep going man 💪
Thanks man, as always I am out of words to appreciate how well you explained everything.
welcome 🙏🏼
i always appreciate when you mention similar problems and give overview about prerequisites
I'm glad you find that helpful!
Crystal Clear 🔥 Explaination! 👌🏻 Thank you TechDose for Superb Explaination 🔥👏🏻👏🏻! Quality of Content++!
Thanks for the appreciation 🙏🏼
How can someone be so good at explaining!!
by god’s grace 🙏🏼
Thanks for your appreciation
I tried to read the editorial on leetcode and didn't quite get it. Then came here and now it all makes sense! Great job TechDose
Thanks
Superb explaination ❤
Thanks :)
Great video! Thank you!
welcome :)
Thank You Sir
welcome
Thank you sir :)
You're welcome :)
brilliant sir
Thanks :)
Nice
👍🏼
Why finding diameter of each component will not work here ?
my bad, the graph can be cyclic here. So we can't directly find the diameter as we do for acyclic graph
Its not a tree but graph :)
java code is not there in code file
use chatgpt to translate it , it's easy to get c++ to java translated
Thanks for reminder.
Updated Java & Python codes
sir it is giving TLE
it’s working fine.
maybe you have missed dfs visited maker somehow.
you need to revisit and match line by line
thanks sir , we can calculate diameter in step 3 of algo which reqires only 2 bfs passes ,
yes
but finding diameter and using bfs may not always be correct.
n = 16
[[16,8],[6,5]]
Expected: 16
could you explain how??? 16
bacause there are 16 nodes.
Each node not having edge forms separate separate groups.
Here 12 nodes are alone so 12 groups for that.
Next you have 4 groups for nodes mentioned in edgelist.
The graph has two disconnected parts
>One part connects nodes 16 and 8
>The other part connects nodes 6 and 5
Since, these parts are separate and have no connections to each other, we can assign each node to its own group without breaking the rule that connected nodes must be in adjacent groups. because there are no extra constraints every node can be in a unique group
This means the maximum number of groups is 16 which is total number of nodes.