Weekly Contest 312 | 2421. Number of Good Paths

  Рет қаралды 7,278

codingMohan

codingMohan

Күн бұрын

Пікірлер: 51
@ashvinkumhar5819
@ashvinkumhar5819 Жыл бұрын
Respect +++++++++++++++ , As always best content 💯💯💯💯💯
@unknown380
@unknown380 7 ай бұрын
Your explanation is awesome man.
@krishanusaha5212
@krishanusaha5212 4 ай бұрын
Excellent bhaiya.. Can you provide more similar type questions
@josephstark5810
@josephstark5810 Жыл бұрын
one optimization while considering the edges in adj. list only consider a->b (when a is greater then b) or b->a(when b is greater then a) tell why? because when we only go from large value to small not need to mark activated nodes
@nabajyotimajumdar4511
@nabajyotimajumdar4511 5 ай бұрын
Quality content!
@paraspandey577
@paraspandey577 2 жыл бұрын
Excellent explanation man. Using the idea of stitching up the graph instead of breaking the graph is brilliant.
@hemanthkumartirupati
@hemanthkumartirupati Жыл бұрын
Best explanation video on youtube
@akshayyadav112
@akshayyadav112 Жыл бұрын
now i am more confused, but u explained well
@anvesh5377
@anvesh5377 2 жыл бұрын
Instead of creating is_active array, at the time of creating adj list we add a edge if vals[u] >= vals[v] then G[u].push_back[v] else G[v].push_back[u] . This thing makesures that the bigger value nodes connected to smaller value nodes at the time union operation. And also time complexity will be reduced since the number of adj_nodes are less for a node.
@codingmohan
@codingmohan 2 жыл бұрын
Overall time complexity will not be affected as in this case you are just iterating over all the edges exactly twice and in your approach we'll be iterating over edges exactly once. But yes, this will remove the need of "is_active" array. Good point :)
@JohnWick-kh7ow
@JohnWick-kh7ow Жыл бұрын
What is the time and space complexity of the solution?
@hemantranjan2297
@hemantranjan2297 Жыл бұрын
Time Complexity: O(n), Space Complexity: O(n)
@JohnWick-kh7ow
@JohnWick-kh7ow Жыл бұрын
@@hemantranjan2297 how?
@hemantranjan2297
@hemantranjan2297 Жыл бұрын
​@@JohnWick-kh7ow As we are iterating over all the valued nodes once, and findLeader(Time complexity would be inverse Ackermann function i.e
@blasttrash
@blasttrash Жыл бұрын
@@hemantranjan2297 what about sorting? it should be nlogn for TC i think. Even on leetcode they mention nlogn for TC.
@sunilpanchal1498
@sunilpanchal1498 Жыл бұрын
Super Explanation 😃😃
@bitterthread6794
@bitterthread6794 2 жыл бұрын
This question was well formed for HARD category and well explained here..
@mr.s7767
@mr.s7767 Жыл бұрын
If I use nC2 formula it doesn't work. But it works if I use n * ((n - 1)/2). Why?
@HARSHYADAV-qe9zz
@HARSHYADAV-qe9zz 9 ай бұрын
when you use nC2 formula it will calculate factorial for 'n' and 'n-2' then it divides them to get the result. The values are quite huge and it also take some time. Maybe that's why it was not working.
@thedevtutorials
@thedevtutorials Жыл бұрын
Epic Explanation !!!
@akashyadav3211
@akashyadav3211 Жыл бұрын
Damn...thanks u cleared my doubt xC2
@niladrisekharnath
@niladrisekharnath 2 жыл бұрын
Great Explanation Thank You so much
@freezefrancis
@freezefrancis Жыл бұрын
Simple explaination to very hard problem. Well done. I could immediately code it up after watching your video.
@arnabnandy2828
@arnabnandy2828 Жыл бұрын
Excellent explanation
@hymnish_you
@hymnish_you 2 жыл бұрын
Cool explanation!!! Bro, I came up with the solution but I am hell lazy to get it implemented. Slept just 4 hours ;( Anyways will try my best next time.
@codingmohan
@codingmohan 2 жыл бұрын
Next time you get the same feeling, make sure to copy-paste DSU code from somewhere (you can use mine if you want :P) and write the core logic :)
@giraffe4375
@giraffe4375 2 жыл бұрын
thanks
@varunmanchanda3972
@varunmanchanda3972 2 жыл бұрын
Is this Small to Large DSU based question?
@codingmohan
@codingmohan 2 жыл бұрын
Not really. This problem doesn't really depends on that concept. This just exercised DSU to keep track of the connected component.
@codingwithanonymous890
@codingwithanonymous890 Жыл бұрын
I am still having hard time understanding any good blogfor this pls suggest
@Truysジャ
@Truysジャ Жыл бұрын
Nice explanation sir
@Heartless-he8km
@Heartless-he8km Жыл бұрын
dimag ka dahi kar diya bhai aapne.
@streetcode4284
@streetcode4284 2 жыл бұрын
Amazing explanation
@lofibeats2344
@lofibeats2344 2 жыл бұрын
Why you didnot upload maximum and su string solution?
@codingmohan
@codingmohan 2 жыл бұрын
Do you want me to record it? I looked at it after 20 mins into the contest and already 6K+ people had solved it. So, haven't uploaded it. I can upload it if you feel that I can add some value. Let me know :)
@lofibeats2344
@lofibeats2344 2 жыл бұрын
@@codingmohan yes this type of problems are coming frequently in recent contest.
@jaddajaswanthkumar1164
@jaddajaswanthkumar1164 2 жыл бұрын
Superb explanation bro
@shubhankarnath7573
@shubhankarnath7573 2 жыл бұрын
This solution is really really awesome bro , nice thought 😎🔥
@karannnful
@karannnful 2 жыл бұрын
time complexity?
@rohit9003
@rohit9003 2 жыл бұрын
This is my first time watching your video and i understood it in one go , gg great explanation !!!
@prafullprajapati3643
@prafullprajapati3643 2 жыл бұрын
good explaination
@mohdaasimqureshi7115
@mohdaasimqureshi7115 2 жыл бұрын
Great Explanation 👏👏👏
@SHREYANSHSHARMA-y9o
@SHREYANSHSHARMA-y9o Жыл бұрын
big Fan sir
@XxelitebeautyxX
@XxelitebeautyxX 2 жыл бұрын
Amazing work!
@laxmikanthreddy4393
@laxmikanthreddy4393 2 жыл бұрын
Excellent explanation bro . Keep posting you will definitely gonna reach large number of audience
@codingmohan
@codingmohan 2 жыл бұрын
Thank you so much 🙂
@aayush5474
@aayush5474 2 жыл бұрын
excellent explanation. Subscribed
@devendrapatil07
@devendrapatil07 Жыл бұрын
op🔥
@TusharKumar-u4p
@TusharKumar-u4p 4 ай бұрын
Google OA
@_MS98
@_MS98 Жыл бұрын
Thanks
@SDE-wq4tl
@SDE-wq4tl Жыл бұрын
amazing explanation
Weekly Contest 313  |  6194. Minimize XOR
9:39
codingMohan
Рет қаралды 720
2876. Count Visited Nodes in a Directed Graph |  Weekly Leetcode 365
19:37
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,5 МЛН
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 102 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,6 МЛН
2421. Number of Good Paths | LeetCode | C++
21:42
DeepCodes
Рет қаралды 1,4 М.
Number of Good Paths - Leetcode 2421 - Python
25:13
NeetCodeIO
Рет қаралды 13 М.
Coding Unbreakable Encryption in C | One-Time Pad
17:42
HirschDaniel
Рет қаралды 4,8 М.
3251. Find the Count of Monotonic Pairs II | Weekly Leetcode 410
33:04
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 215 М.
Biweekly Contest 88  |  6198. Number of Pairs Satisfying Inequality
18:35
ТЫ В ДЕТСТВЕ КОГДА ВЫПАЛ ЗУБ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,5 МЛН