Diameter Of Undirected Graph | Tree Diameter | Leetcode 1245 | Graph Concepts & Qns - 44 | MIK

  Рет қаралды 4,046

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 38
@NikhilYadav-i2f
@NikhilYadav-i2f 6 сағат бұрын
Feels so honoured that He is my college alumni, absolute goated stuff Bhaiya🦾
@codestorywithMIK
@codestorywithMIK 6 сағат бұрын
This means a lot ❤️🙏
@NikhilYadav-i2f
@NikhilYadav-i2f 5 сағат бұрын
@@codestorywithMIK Can we connect by any means, Bhaiya? Need some advice regarding tech stuffs and hiring, this year has been drastic for us with regards to internship and placement.
@codestorywithMIK
@codestorywithMIK 13 сағат бұрын
NOTE - The diameter of a tree or graph represents the longest path between any two nodes, and this path does NOT contain any REPEATED edges or nodes. Today's POTD Link - kzbin.info/www/bejne/q6vCiHyJpd6GfNU
@ShivamSharma-vf4uf
@ShivamSharma-vf4uf 5 сағат бұрын
SIR PLEASE SOLVE 21 DEC AND 22 DEC Problem of the day as you skipped these problems on that day
@sumitgupta310
@sumitgupta310 11 сағат бұрын
Leetcode : 3203 (using video Explaination) sol : class Solution { public: pair bfsTofindFarthestNode(int s, int v, unordered_map& adj) { vector vis(v, false); queue q; q.push(s); vis[s] = true; // Mark starting node as visited int level = 0, farthestNode = s; while (!q.empty()) { int n = q.size(); for (int i = 0; i < n; i++) { int node = q.front(); q.pop(); farthestNode = node; for (auto it : adj[node]) { if (!vis[it]) { vis[it] = true; // Mark neighbor as visited before enqueueing q.push(it); } } } if (!q.empty()) level++; } return {farthestNode, level}; } int treeDiameter(vector& edges) { int v = edges.size() + 1; // Number of nodes unordered_map adj; for (const auto& edge : edges) { int u = edge[0], v = edge[1]; adj[u].push_back(v); adj[v].push_back(u); } auto oneEndNode = bfsTofindFarthestNode(0, v, adj); auto otherEndNode = bfsTofindFarthestNode(oneEndNode.first, v, adj); return otherEndNode.second; // Diameter of the tree } int minimumDiameterAfterMerge(vector& edges1, vector& edges2) { int dia1 = treeDiameter(edges1); int dia2 = treeDiameter(edges2); int combinedDia = ceil(dia1 / 2.0) + ceil(dia2 / 2.0) + 1; return max({dia1, dia2, combinedDia}); } };
@gui-codes
@gui-codes 12 сағат бұрын
Done and crystal clear. These concepts I was not even taught in a paid course I took years ago. I wish I had found you earlier. Waiting for today's POTD now.
@aws_handles
@aws_handles 11 сағат бұрын
Man you are a legend and so hard working. Thank you for clearing the concepts. Now I can understand the POTD
@Abraham33286
@Abraham33286 6 сағат бұрын
Your explanation is unbeatable.
@SiddheshPardeshi-mp9cr
@SiddheshPardeshi-mp9cr 7 сағат бұрын
Amazing explanation, Keep the good work
@abhinay.k
@abhinay.k 8 сағат бұрын
20:14
@I_Love_You_Mansi_Forever
@I_Love_You_Mansi_Forever 5 сағат бұрын
mik sir you are so underrated!!
@k-CE-OmkarPathak
@k-CE-OmkarPathak 12 сағат бұрын
Great concepts
@Coder_Buzz07
@Coder_Buzz07 14 сағат бұрын
First view😍❤
@gui-codes
@gui-codes 14 сағат бұрын
Wow. Thanks a lot MIK. Was waiting for this one.
@metirajendar6396
@metirajendar6396 9 сағат бұрын
What if the node 5 has two child nodes(say 10 and 11) in the dry run? Do we get multiple options for diameters? How does this effect the diameter paths(having multiple paths with diameter k)?
@varunaggarwal7126
@varunaggarwal7126 10 сағат бұрын
I made silly mistakes during oa rounds due to stress, later I was able to solve 😭😭
@abhinay.k
@abhinay.k 8 сағат бұрын
Thanks sir
@vaibhavyadav3301
@vaibhavyadav3301 12 сағат бұрын
Bro your whole content is aroud dsa and leetcode, you should take the premium again 😅
@anshuman5554
@anshuman5554 11 сағат бұрын
Sir, expedia group USA ke liye refer kr skte ho kya? i am doing my masters here
@amardeep7714
@amardeep7714 4 сағат бұрын
MIK , plz 1 vdeo on Bridge of graph....i knw ki dfs s hoga ..time stamp discovery and finish time ka concept h but still achhe s clear nai hua h...so plz try to bring that too.. Also i am placed in campus in PSU with 21 ctc. Thankyou so much for everything .
@ShivamSharma-vf4uf
@ShivamSharma-vf4uf 10 сағат бұрын
SIR PLEASE SOLVE 21 DEC AND 22 DEC Problem of the day as you skipped these problems on that day @codestorywithMIK
@RishabhChatterjee-fg2gz
@RishabhChatterjee-fg2gz 6 сағат бұрын
Bhaiya mathematical proof wala ek baar firse samjha do, Aur Bhaiya d(u,a) > d(u,b) ho sakta hai aap jo diagram liye uske basis pe aagar mein u ko b se 1 distance pe rakhu, ye wala thik se samajh nhi aaya, mathematical wala ek baar aur Bhaiya please
@ashutoshchouhan9610
@ashutoshchouhan9610 Сағат бұрын
14:24 🔔 vo yaha kisa lye karaga 😂😂🤣
@aadityaraj2397
@aadityaraj2397 6 сағат бұрын
ye question CSES sheet me bhi hai
@yogendrakesharwani3650
@yogendrakesharwani3650 3 сағат бұрын
I am not able to search for leetcode POTD section. Where is that section ?
@codestorywithMIK
@codestorywithMIK 2 сағат бұрын
kzbin.info/www/bejne/q6vCiHyJpd6GfNUsi=btJ8DB81bcdJITlu
@pradeepgpt
@pradeepgpt 41 минут бұрын
Its daily challenge problems, You can find in the right side of the problem section.(Looks like calendar)
@varunpalsingh3822
@varunpalsingh3822 11 сағат бұрын
MIK ek roadmap bana sakte ho ? How to get good tech job in 2025 I sometimes got distract from my path ki what how and where to do
@HeetVichhivora
@HeetVichhivora 12 сағат бұрын
Mik bhaiya perso ka video please
@anshkapooriitb6458
@anshkapooriitb6458 13 сағат бұрын
2940. Find Building Where Alice and Bob Can Meet solution video please
@codestorywithMIK
@codestorywithMIK 13 сағат бұрын
coming today.
@sarangkale6761
@sarangkale6761 14 сағат бұрын
Sir Aaj POTD nhi solve karenge?
@codestorywithMIK
@codestorywithMIK 14 сағат бұрын
Definitely it will come. But before solving today's POTD, this video is going to be very important. Do watch this one because we will directly use the code of this video to today's POTD.
@sarangkale6761
@sarangkale6761 14 сағат бұрын
@codestorywithMIK yess sir
@meetdobariya8777
@meetdobariya8777 10 сағат бұрын
Last two days
번쩍번쩍 거리는 입
0:32
승비니 Seungbini
Рет қаралды 182 МЛН
OCCUPIED #shortssprintbrasil
0:37
Natan por Aí
Рет қаралды 131 МЛН
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
Data Structures - Tree & Graph | Concept & Questions | Arora Educator |
1:00:00
Lecture 88: Cycle Detection in Undirected Graphs || Using BFS and DFS
32:03
CodeHelp - by Babbar
Рет қаралды 149 М.
Quiet Night: Deep Sleep Music with Black Screen - Fall Asleep with Ambient Music
3:05:46
The Best Software Engineering Advice | Prime Reacts
55:05
ThePrimeTime
Рет қаралды 469 М.
Ep : 5 I Jain Philosophy: An Introduction I Dr Vikas Divyakirti
3:29:27
Vikas Divyakirti
Рет қаралды 11 МЛН
번쩍번쩍 거리는 입
0:32
승비니 Seungbini
Рет қаралды 182 МЛН