BS-21. Median of two Sorted Arrays of Different Sizes | Binary Search Approach With Intuition
Problem Link: bit.ly/43QDw96
Brute and Better: • BS 21: Median of two S...
Notes/C++/Java/Python codes:
We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of Course
Пікірлер: 301
There is no way that you can come up with this optimal solution in an interview. Although the better solution using merge procedure from merge sort was pretty thinkable and doable but this is a completely genius solution !!!
@titusandronikus1337
3 ай бұрын
I came up with it on my own when solving it on Leetcode. Let’s be honest, the main idea is not very hard. But my problem was the actual implementation. You can see in the video just how many random +1 and -1 we need, as well as boundary checks. It’s crazy. I hoped Striver would find a way to make the code less ugly - sadly, no. The problem is just inherently very annoying
@abhik6400
3 ай бұрын
@@titusandronikus1337 Really glad that you were able to come with the optimal solution on your own !!!!
@priyanshurana6027
Ай бұрын
I came up with different approach on this one when solving on my own. It's similar to what we do in matrix's binary search I guess ( I have not watched striver's videos on it). Basically searching for kth element in any sorted arrays. It took O( log(m*n)*log(max-min)) time complexity, pretty big but it's in log and was accepted in leetcode.
@cosmicthor7330
Ай бұрын
@@titusandronikus1337 same thought process is thinkable but seriously the implementation is though,hoestly i didnt understand fully
@rajat5040
14 күн бұрын
@abhik6400 can u tell how it is doable from merge sort???
The going into recursion for swapping idea was 🔥
@easylearn8924
8 ай бұрын
can you explain why he does that?? or we also use min(n1,n2) but it gives runtime error why??
@tovenkatesh82
8 ай бұрын
@@easylearn8924 the idea is to do a binary search over the smaller-size array. while loop is written based on that and that's why using min(n1,n2) would give you error.
@easylearn8924
7 ай бұрын
ok thanks@@tovenkatesh82
@ashish4k07
7 ай бұрын
@@easylearn8924 If we do that that's also possible but the code complexity will be too large and the std. while loop of binary search won't work even I understood after that video.
@easylearn8924
7 ай бұрын
why it won't work in while loop can you explain?? because i able to understand but after sometime i confused in this part??@@ashish4k07
I am so dumb even after solving good number of questions on leetcode I even could not even think of like this.
He has already explained this in sde sheet but still he made a video for a2z sheet💯
@farazahmed7
9 ай бұрын
On which sheet has he explained this ? can you give me the link. Thanks
@mrlord8519
7 ай бұрын
@@farazahmed7maybe from his sde sheet for placements
@omkarshendge5438
7 күн бұрын
@@farazahmed7 i think he is talking about the placement series or the sde sheet of 180 questions he made long time ago, you should check that out.
Watched both videos twice ,all 3 approaches are crystal clear now,thank you!
Waiting for this one for a long time no one explained this problem this well , Thank you.
Such a thorough explanation! Exactly what I needed to help me understand this problem. Great energy throughout and the lesson was clearly well prepared and organized to educate and enlighten. Thank you!
This is one of the bestest explanations I have come across. Totally cleared my concept. Thanks a lot sir !
Striver you are a real social reformer. At times when colleges are rendering students unemployable , you are making us industry ready. Dude Hats off to you.
After watching so many videos i actully the found the gem which resolved my all the doubts in such a nice and simple way.
Crystal clear explanation. Explained your heart out. Thank you :)
Understood! Super amazing explanation as always thank you very very much for your effort!!
Once again, your explanation is top-notch.
best video of entire playlist. I never understood this problem's binary search approach earlier, but you solved it so well. And that idea to call that function again if sizeof(b)
@user-cd7lf8nk4c
Ай бұрын
Why we need to do that ? Can you explain
@Beeplov2337568
13 күн бұрын
@@user-cd7lf8nk4cIt might possible that the first array has greater size,so in order to take the shorter array to proceed he did it, hence TC : O(log(min(n1,n2)))
That swapping of the inputs and >>1 steps are 🔥 🔥
@ashish4k07
7 ай бұрын
bit manupulation and swapping is to low so yeah it improves time mostly
Best video explanation of this problem on the whole internet.
If i hadn't checked this video there is no way i would be able to think of this solution in interview Thanks...
TOP notch explanation striver. I saw both videos. Understood completerly. Thank you.
What a energy ! Thank you striver for amazing content 🙇
Understood. GOod video striver. It's important to watch these important questions because it is not possible to invent these kind of solutions then and there itself.
brilliant explanation. even hard topics seem easy when you explain them.
You deeply understand the problem and explain the solution well. Thanks.
Brilliantly explained!!
brilliant explanation, this problem is not only hard to do but also hard to explain
Understood!! Amazing explanation
I wanna know, how you built your logic and how you became an expert in understanding this logic so well. I have been following your playlist for a couple of months and understood each problem so well. What steps do you follow in your initial stage to reach this point? Please help so that your valuable tips can help me crack coding interviews. Trust me you are simply Amazing and Genius :)
Amazing, how you observe so minutely :) Bhai Hat's Off .
UNDERSTOOD..........Thank You So Much for this wonderful video................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
I shocked at the end of video after seeing the way you explained this complex optimal solution!!!! Thanks a lot!❤🔥💥❤💯
The king of coding community 👑
Really wonderful approach and explanation
Thanks striver to explain this . I was thinking that this is too much difficult concept but after watching this video , I can do the similar stuff myself. Thank you so much
Great explaination..Thank you.💯
Excellent explanation!!💌
Amazing Explanation! Thanks!
Loved this approach❤
Hats off to you Broh... THANKS A MILLION 💙💙💙
At first the brain wasn't braining but got it at the end great explanation
I did it using the approach of two sorted lists question and got 2ms solution. But this is better
Wow explanations. Big Thanks to Striver.
Great explanation. Thank you ❤
Hi bro . Recently i started to watch your array playlist. Today i watching this median problem . I clearly understood your logic at first time itself . I really amazed with your logical thinking . How could you come up with this logic . You are making me logical thinking and programming more interesting. I am started to learn all the concept . Now i am following logic which is already there. But the way you are approaching all the problem with different optimal solution, its very unpredictable. Please provide some tips how you have build your logic on each ptogram when you started your coding journey. That would help most of the freshers. Thank you!
Thanks Bhai. Its a tough question, but explained it very nicely.
great explanation buddy. Keep up the good work.
Thank you Striver sir 🥰
great video, thanks for this
Thank you Striver💖💖
This is the first video that I have not understood of you. No matter how many times I watch I just can't understand. I'm just skipping this optimal approach for now. :)
this tutorial is awesome, thanks for this :)
very well explained!!!
CLEAN AS ALWAYS
Understood! Thanks!!
awesome explanation
Understood bhaiya 😊
Mind blowing video❤
Best Explanation!!
Thank u for doing things for us even in ur busy days...❤
@Sports590
11 ай бұрын
"Busy" are those People who disrespect others, People who respect are not Busy ❤
Thank you, Sir ! :)
Great.. You are the best
At 17:57 shouldn't it be l1 > r2?
@rushidesai2836
Ай бұрын
Same thing i was thinkking
brilliant explanation
Brilliant. Thanks!
Understood, thank you.
hats of to your efforts
great explanation
Finally Understood man.
before watching this intution , my favourite intution was dutch national flag algo,,, but this question along with its explanation was beyond my imagination,,,, hats off to you.......and your expression after completing this ques shows how passionate you are about your work and this gives us too much motivation,,,thank you😇😇
@arjunc1482
5 ай бұрын
bro..how will you use dutch national flag algo for this question?
@ArpanChakraborty-do6yz
5 ай бұрын
@@arjunc1482 I am not saying I will use duch algo here,,, I have just stated among all algo/intuitions duch algo and it's question was my fav,,, but after watching this question and it's soln , it is my fav now
it was superb................
one of best video on yt
@45vinitthakkar56
Ай бұрын
hello
1 morning i would woke up and see striver had completed a2z series and i got my dream company.
I still can't imagine how would someone think of such an optimal solution? It's out of mind. Are we expected to think of such optimal soln? I'm asking this bcz, it took me lot of time to understand this soln even after a great explanation... Thank you striver for such a wonderful explanation !
your explanation is awesome 😇😇. Finally i can rest in peace🙃
Understood salute to striver🤓
Awesome !👍
very helpful thanks bhaiya
Thank you bhaiya
over the top bhaiya
Understood, Thank U
understood. Thanks
You are the best
really well understood
Loved it!
thankyou. this is best
Thank you
superb... thanks.
Thank you striver sir
Hatts of you best best best🎉🎉🎉
amazing!!!
Understood !! 😎😎
Thank you so much sir
great work!!
@45vinitthakkar56
Ай бұрын
hello
Understood!!
Understood !
Great ✨✨✨
Understood sir!!
Understood✅🔥🔥
Maza aayaaa💥💥💥
thanks!
Understood sir
understood!!!😀