BS-21. Median of two Sorted Arrays of Different Sizes | Binary Search Approach With Intuition

  Рет қаралды 148,866

take U forward

take U forward

Күн бұрын

Пікірлер: 331
@abhik6400
@abhik6400 4 ай бұрын
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
@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
@abhik6400 3 ай бұрын
@@titusandronikus1337 Really glad that you were able to come with the optimal solution on your own !!!!
@priyanshurana6027
@priyanshurana6027 2 ай бұрын
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
@cosmicthor7330 2 ай бұрын
@@titusandronikus1337 same thought process is thinkable but seriously the implementation is though,hoestly i didnt understand fully
@rajat5040
@rajat5040 Ай бұрын
@abhik6400 can u tell how it is doable from merge sort???
@ravirajshelar250
@ravirajshelar250 10 ай бұрын
The going into recursion for swapping idea was 🔥
@easylearn8924
@easylearn8924 9 ай бұрын
can you explain why he does that?? or we also use min(n1,n2) but it gives runtime error why??
@tovenkatesh82
@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
@easylearn8924 8 ай бұрын
ok thanks@@tovenkatesh82
@ashish4k07
@ashish4k07 8 ай бұрын
@@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
@easylearn8924 8 ай бұрын
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
@user-sv6hh4gt4z
@user-sv6hh4gt4z 6 ай бұрын
I am so dumb even after solving good number of questions on leetcode I even could not even think of like this.
@user-ft1dn8mv8s
@user-ft1dn8mv8s 5 күн бұрын
same same
@arpitgoyal2035
@arpitgoyal2035 4 күн бұрын
you just have to understand all the concept better and try to practice more problems on your own and like solve some old problems as well to strength your concepts and get motivation.
@sanketkumbhar8887
@sanketkumbhar8887 11 ай бұрын
He has already explained this in sde sheet but still he made a video for a2z sheet💯
@farazahmed7
@farazahmed7 10 ай бұрын
On which sheet has he explained this ? can you give me the link. Thanks
@mrlord8519
@mrlord8519 8 ай бұрын
​@@farazahmed7maybe from his sde sheet for placements
@omkarshendge5438
@omkarshendge5438 Ай бұрын
@@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.
@ruturajchandgude6083
@ruturajchandgude6083 10 ай бұрын
Watched both videos twice ,all 3 approaches are crystal clear now,thank you!
@harshit.53
@harshit.53 3 ай бұрын
If i hadn't checked this video there is no way i would be able to think of this solution in interview Thanks...
@yatendraupadhyay2180
@yatendraupadhyay2180 3 ай бұрын
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.
@shubhambagul3127
@shubhambagul3127 11 ай бұрын
Waiting for this one for a long time no one explained this problem this well , Thank you.
@harshhwardhanrai3716
@harshhwardhanrai3716 Ай бұрын
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. :)
@Dontpushyour_luck
@Dontpushyour_luck 9 ай бұрын
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
@user-cd7lf8nk4c 2 ай бұрын
Why we need to do that ? Can you explain
@Beeplov2337568
@Beeplov2337568 Ай бұрын
@@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)))
@JeffreyConcerto
@JeffreyConcerto 10 ай бұрын
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!
@SwatiSingh-ys6hm
@SwatiSingh-ys6hm 10 ай бұрын
This is one of the bestest explanations I have come across. Totally cleared my concept. Thanks a lot sir !
@t3ch_r4id
@t3ch_r4id 13 минут бұрын
Thanku for making optimal vedio separately for this problem 🥲❣️🙌🏻
@mrsmurf911
@mrsmurf911 9 ай бұрын
That swapping of the inputs and >>1 steps are 🔥 🔥
@ashish4k07
@ashish4k07 8 ай бұрын
bit manupulation and swapping is to low so yeah it improves time mostly
@Dipanshutripathi2407
@Dipanshutripathi2407 10 ай бұрын
After watching so many videos i actully the found the gem which resolved my all the doubts in such a nice and simple way.
@prajaktachachad477
@prajaktachachad477 5 ай бұрын
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 :)
@rahulseetharaman4525
@rahulseetharaman4525 10 ай бұрын
Crystal clear explanation. Explained your heart out. Thank you :)
@cinime
@cinime Жыл бұрын
Understood! Super amazing explanation as always thank you very very much for your effort!!
@utsavseth6573
@utsavseth6573 11 ай бұрын
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.
@pranavindore2410
@pranavindore2410 9 ай бұрын
TOP notch explanation striver. I saw both videos. Understood completerly. Thank you.
@technicalworld6470
@technicalworld6470 10 ай бұрын
What a energy ! Thank you striver for amazing content 🙇
@shikhirkalia6828
@shikhirkalia6828 8 ай бұрын
Best video explanation of this problem on the whole internet.
@dxvya23
@dxvya23 10 ай бұрын
Once again, your explanation is top-notch.
@sibashis_12
@sibashis_12 9 ай бұрын
brilliant explanation. even hard topics seem easy when you explain them.
@Josuke217
@Josuke217 10 күн бұрын
This is a great approach, no way I could come up with this in an interview...
@linhnguyenduc641
@linhnguyenduc641 4 ай бұрын
You deeply understand the problem and explain the solution well. Thanks.
@sahilbani7020
@sahilbani7020 10 ай бұрын
brilliant explanation, this problem is not only hard to do but also hard to explain
@amitranjan6998
@amitranjan6998 11 ай бұрын
Amazing, how you observe so minutely :) Bhai Hat's Off .
@shshnk11
@shshnk11 11 ай бұрын
Brilliantly explained!!
@VikasSharma-eg8mc
@VikasSharma-eg8mc Жыл бұрын
Understood!! Amazing explanation
@Health_asset
@Health_asset Ай бұрын
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
@aruna5869
@aruna5869 Ай бұрын
I shocked at the end of video after seeing the way you explained this complex optimal solution!!!! Thanks a lot!❤‍🔥💥❤💯
@stith_pragya
@stith_pragya 5 ай бұрын
UNDERSTOOD..........Thank You So Much for this wonderful video................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@ashwingoel7173
@ashwingoel7173 5 ай бұрын
At 17:57 shouldn't it be l1 > r2?
@rushidesai2836
@rushidesai2836 2 ай бұрын
Same thing i was thinkking
@shashankarora2945
@shashankarora2945 4 күн бұрын
Explained so smoothly🔥🔥
@dhananjayadhari6481
@dhananjayadhari6481 5 ай бұрын
Really wonderful approach and explanation
@jugnugupta6839
@jugnugupta6839 11 ай бұрын
Great explaination..Thank you.💯
@joeljacob4685
@joeljacob4685 9 ай бұрын
Excellent explanation!!💌
@BookJournalWithMimansa
@BookJournalWithMimansa 2 ай бұрын
Amazing Explanation! Thanks!
@Anshydv3
@Anshydv3 11 ай бұрын
The king of coding community 👑
@welcometoc.s.easpirants
@welcometoc.s.easpirants 4 ай бұрын
Great explanation. Thank you ❤
@abhicasm9237
@abhicasm9237 10 ай бұрын
I did it using the approach of two sorted lists question and got 2ms solution. But this is better
@andycharlie3255
@andycharlie3255 11 ай бұрын
great video, thanks for this
@jaypratap3888
@jaypratap3888 3 ай бұрын
Thanks Bhai. Its a tough question, but explained it very nicely.
@beinginnit
@beinginnit 11 ай бұрын
Thank you Striver💖💖
@edulacharmi3336
@edulacharmi3336 10 ай бұрын
very well explained!!!
@sauravsarkar4785
@sauravsarkar4785 6 ай бұрын
great explanation buddy. Keep up the good work.
@user-kc4yv5kt3j
@user-kc4yv5kt3j 11 ай бұрын
Wow explanations. Big Thanks to Striver.
@maneeshkumarpatel9874
@maneeshkumarpatel9874 Ай бұрын
Loved this approach❤
@playwithlinux
@playwithlinux Ай бұрын
Hats off to you Broh... THANKS A MILLION 💙💙💙
@PrashantSingh.
@PrashantSingh. 7 ай бұрын
hats of to your efforts
@sumitkamble_
@sumitkamble_ 11 ай бұрын
At first the brain wasn't braining but got it at the end great explanation
@nandini62
@nandini62 21 күн бұрын
Thank you so much broo for these series ☺️
@rajnandinipatel81
@rajnandinipatel81 7 ай бұрын
brilliant explanation
@javabytharun
@javabytharun 20 күн бұрын
awesome explanation
@shivanibharti4774
@shivanibharti4774 8 ай бұрын
Great.. You are the best
@user-jg2xe3np6w
@user-jg2xe3np6w 10 күн бұрын
love your lectures
@nitishjaswal7564
@nitishjaswal7564 11 ай бұрын
Thank you Striver sir 🥰
@ujjawalasable1754
@ujjawalasable1754 10 ай бұрын
great explanation
@ankitsharda1131
@ankitsharda1131 7 ай бұрын
Best Explanation!!
@lalitbisht8381
@lalitbisht8381 4 ай бұрын
Mind blowing video❤
@souvikcseiitk
@souvikcseiitk 27 күн бұрын
this tutorial is awesome, thanks for this :)
@mano_003
@mano_003 Жыл бұрын
Thank u for doing things for us even in ur busy days...❤
@Sports590
@Sports590 Жыл бұрын
"Busy" are those People who disrespect others, People who respect are not Busy ❤
@ReD4eva94
@ReD4eva94 5 ай бұрын
Brilliant. Thanks!
@snehachauhan237
@snehachauhan237 Ай бұрын
it was superb................
@user-jg9vc7mf1e
@user-jg9vc7mf1e 27 күн бұрын
your explanation is awesome 😇😇. Finally i can rest in peace🙃
@lakeshkumar1252
@lakeshkumar1252 11 ай бұрын
very helpful thanks bhaiya
@yasaswinikarumuri9590
@yasaswinikarumuri9590 Ай бұрын
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 !
@aarzoo2302
@aarzoo2302 10 ай бұрын
great work!!
@45vinitthakkar56
@45vinitthakkar56 2 ай бұрын
hello
@OIAOa
@OIAOa 11 ай бұрын
Understood bhaiya 😊
@abhaythakur2597
@abhaythakur2597 6 ай бұрын
really well understood
@NazeerBashaShaik
@NazeerBashaShaik 3 ай бұрын
Understood, thank you.
@himanshujain8176
@himanshujain8176 8 ай бұрын
superb... thanks.
@jaswanthtr4588
@jaswanthtr4588 11 ай бұрын
Awesome !👍
@nayankhuman1043
@nayankhuman1043 7 күн бұрын
Understood 😊. You d best ❤
@harshitjaiswal9439
@harshitjaiswal9439 6 ай бұрын
Loved it!
@ArpanChakraborty-do6yz
@ArpanChakraborty-do6yz 6 ай бұрын
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
@arjunc1482 5 ай бұрын
bro..how will you use dutch national flag algo for this question?
@ArpanChakraborty-do6yz
@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
@ayushhagarwal
@ayushhagarwal Ай бұрын
Understood! Thanks!!
@RGUKTEDUIN
@RGUKTEDUIN 6 ай бұрын
Understood salute to striver🤓
@pratulyapratap9329
@pratulyapratap9329 6 ай бұрын
Maybe it will help :) int mid2 = left - mid1; // left = how many elements i can pickup mid1 = how many i have picked up
@kynjribajwatmarbaniang8659
@kynjribajwatmarbaniang8659 10 ай бұрын
thankyou. this is best
@we_atheletes
@we_atheletes 8 ай бұрын
one of best video on yt
@45vinitthakkar56
@45vinitthakkar56 2 ай бұрын
hello
@KESHAVKUMAR-mb2nm
@KESHAVKUMAR-mb2nm 10 ай бұрын
Understood, Thank U
@ShubhamKumar-uf3gc
@ShubhamKumar-uf3gc Ай бұрын
CLEAN AS ALWAYS
@drishtirai864
@drishtirai864 28 күн бұрын
Thank you, Sir ! :)
@charuprabha9696
@charuprabha9696 Ай бұрын
This is a little bit too much for me to digest, but at least I understood most of it.🙂
@user-gj5pv2to9q
@user-gj5pv2to9q Ай бұрын
Hatts of you best best best🎉🎉🎉
@ManavMSanger
@ManavMSanger 8 ай бұрын
understood. Thanks
@asmitraj4740
@asmitraj4740 10 ай бұрын
Finally Understood man.
@Lucifer0872
@Lucifer0872 Жыл бұрын
Thank you bhaiya
@tanushree0106
@tanushree0106 3 ай бұрын
Thank you so much sir
@blue.262
@blue.262 Жыл бұрын
Thank you striver sir
@empvaibhav9799
@empvaibhav9799 2 ай бұрын
The idea clicked the moment he said how many elemts to pick from both the arrays. Started coding it and damn it was tough to code it (edge cases 💀)
@arnab027
@arnab027 11 ай бұрын
1 morning i would woke up and see striver had completed a2z series and i got my dream company.
@shikherdwivedi4559
@shikherdwivedi4559 Ай бұрын
You are the best
@user-xc6ez1kj6q
@user-xc6ez1kj6q 7 ай бұрын
understood!!!😀
@krishnashukla8099
@krishnashukla8099 9 ай бұрын
over the top bhaiya
@arkadiptamojumder3800
@arkadiptamojumder3800 10 ай бұрын
l1 should be greater than r2 right at 17:49 ?
@faizanahmed9304
@faizanahmed9304 9 ай бұрын
Yup
@nishaaa_maurya
@nishaaa_maurya 4 ай бұрын
Hi Striver, It was a great explanation. Thank you !! Can you please explain that, why are taking first vector is always smaller?
@sujeetiitd
@sujeetiitd 7 күн бұрын
At [17:23], you're picking 4 elements from the "Top" (not "Left"). Slips of the tongue make the matter very difficult to follow.
Bs-22. K-th element of two sorted arrays | Binary Search Approach
11:53
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 8 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Launching the best DSA Course + Platform
36:29
take U forward
Рет қаралды 97 М.
Day 125 Of Doing Codeforces Everyday Until I Reach Expert
1:10:20
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 158 М.
One Lore Fact for Every Card in Clash Royale
30:46
ARCTO
Рет қаралды 19 М.
How I Approach a New Leetcode Problem (live problem solving)
25:31
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 366 М.
BS-10. Finding Sqrt of a number using Binary Search
17:11
take U forward
Рет қаралды 111 М.
BS-27. Median in a Row Wise Sorted Matrix
23:13
take U forward
Рет қаралды 79 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 634 М.
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22