Median of Two Sorted Arrays - Optimised Approach | Leetcode 4 Solution | Searching and Sorting
Vložit
- čas přidán 25. 05. 2021
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. Question Statement:
1. Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
Topic: #Array #leetcode4 #SearchingAndSorting
Used #DataStructure: #Array
#TimeComplexity: O(log(n+m))
#SpaceComplexity: O(1)
For detailed information and other exercises, VISIT: www.pepcoding.com
Have a look at our result: www.pepcoding.com/placements
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
----------------------------------------------------------------
#BinarySearch #geeksforgeeks #SearchingAndSorting #leetcode4
For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
Have a look at our result: www.pepcoding.com/placements
Follow us on our CZcams page: / pepcoding
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
Follow us on Pinterest: / _created
Follow us on Twitter: home
.
.
.
Happy Programming !!! Pep it up 😍🤩
.
.
.
#pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer
Instructor put her heart and soul in explaining even the slightest intricacies in the problem. Hats off. These videos deserves much more views than it actually getting.
After reading so many blogs and posts for this post, This is the only video that can explain this question so well. Hats off to the instructor, feels like we are talking to the instructor while she is explaining.
I think this channel deserve more than 2-3 million subscribers
Someone give the my appreciation to this girl. She puts her heart into explaining. Well done 👍 and she is absolutely clear with the concept
Pepcoding has become my goto channel to understand Leetcode hard problems.
Glad you liked it.
Keep learning.
And for better experience and well organised content visit nados.pepcoding.com
pepcoding has best content for dsa over CZcams 🙌🏻
Pepcoding becomes my favorite after watching this vedio.. Amazing explanation !!!
I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
If you like our efforts, we request a review
g.page/Pepcoding/review?rc
You can subscribe to our channel here
czcams.com/users/Pepcodingabout?view_as=subscriber
There is no better explanation for this question than this on entire CZcams.
pepcoding explaination is the best over internet being it any DSA ques
Pepcoding is an emotion of coders♥️🥺
Thank you♥️
i think the complexity is log(min(m,n)) if we always try to do binarySearch on smaller array
This is the best explanation I have got after slogging this question after last 6 months. Best explanation ever.!!!!
Thank you so much.
Glad it helped and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Another best video from PepCoding.
Ooo great summet sir kae badh bhi koi itna accha samghaa . Wonderful
Thank you for giving such a best explaination
Thank you for all the work you guys are doing.
This has been the best explanation ever for this question. Thankyou for your efforts Ma'am.
Literally, East ho ya west only pepcoding is the best!
This is the best explanation on youtube for this problem.
Thank you very much, ma'am! Your explanation was extraordinary.
Best explanation online for this tricky problem. Pepcoding never disappoints.
Its a very detail and simpler explanation for this hard question, I saw 2 or 3 video but this one resolves all my doubts. Thank you
Beautiful Explanation manisha ji.
concept cleared like magic
hats off to mam
Thanks A Lot Akka. ALMIGHTY bless you all with all kinds of wealth.
Amazingly explained. Pepcoding teachers are awesome :)
Maza aa gaya!! 🙌🏻 One more hard ques down!
Thankyou
I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
Great explanation , was struggling with the question . thanks
Best possible explanation.
This is excellent explanation. I would rather watch this type of longer videos over Family man season 2 :)
why not watch both
@@LegitGamer2345 yess😁
arrae samad bahi allahabad balae ho kya bilkul sahi baat hai bhai
Great video! Great efforts Manisha
Awesome explanation, worth millions.
Such a nice explanation and I really appreciate that hardwork of pepcoding Team. In Future Pepcoding will become Big Brand.
I am from future. Scaler acquired them
after seeing multiple explanations i finally understood it from this one.
Glad that it was helpful. For better experience and precisely arranged content visit on nados.io, also you can post your doubts on community tab on NADOS.
Amazing explanation !!!!!
Great Explanation ma'am!!
great teaching skills
Great explanation!!
Nice explanation Manisha🙂🙂
brilliant finally understood thanks
Amazing Explanation Ma'am😍
Awesome explanations
God level explanation
Great Explanation
absolute gem
Create Maximum Number,Mini Parser,Longest Absolute File Path,Shortest Unsorted Continuous Subarray,Number of Atoms make a video on this ques of leetcode
the complexity is even more efficient its is log(min(m,n)) coz we do binarySearch on smaller array always
Thank you mam, awesome explaination
Thank you for this amazing explanation Ma'am :)
Glad it was helpful. keep motivating, keep learning and keep loving Pepcoding😊
Such an amazing expalanation it was thank you.
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
reminder :-if the total length(arr1length+arr2lenght) would have given that it can be 0 also then we would have to handle one more edge case also .here it is not given so code is working fine .
pep coding rocks
great job, very detailed explanation
Glad it was helpful! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
mam ap explain krne ke time hi=a.length-1 kr rhe the....lekin code me achanak a.length kew kr die???????plz reply
Thanks
Great explanation 🔥🔥thanks a ton mam
Glad to know that you liked the content and thank you for appreciating.
The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
So, keep motivating, keep learning and keep loving Pepcoding😊
thanks alot :)
Such an amazing explanation 😍🤩
Glad you liked it:) To watch more such videos with better user experience go to nados.pepcoding.com
very nice explanation
Thanks for liking. For better experience visit on nados.io
Great mam 🔥🔥
Mazaa aaya!
Important point 57:50
Thank you mam ❤
Very good explanation
Thanks for liking
Awesome explanation😊
Glad you think so! For better experience and well organised content sign up on nados.io and start learning.
Great video !!
Glad you enjoyed it For better experience and well organised content sign up on nados.io and start learning.
[4]
[1,2,3,5,6]
this test case broke my code in leet code
You are the best
wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.
excellent explanation
We are glad that it was helpful for you. For better experience and precisely arranged content visit on nados.io
thank you so much
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
We love you ma'am!
❤️
why we start segregation from (mid - 1) in array a
low---0, high is 3 low+high/2= 1.5
kya bat manisha didi
pr video kafi lambi bn gyi
Where can I find the complete Java code?
Manisha mam bhi macha hi deti hai
greatttt
Thank you so much and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )
when you are trying calculate low=formula is low+high/2
This code will fail for testcase
[1,2,3,5,6]
[4]
bleft goes -2 here after first iteration
also when any array is of 0 length then too it fails
both can be handled by using the smaller array as first array and check for both 0 length array condition
Visit nados.pepcoding.com and sign up to NADOS, to clear your doubts and better experience.
Don't forget to follow us on Instagram instagram.com/pepcoding/
Isn't the time complexity log(min(n,m))?
Correct! But maybe log(n+m) was simpler to write? And still fast enough that one needs to come up with the optimized algorithm...
why high = a.length and not high = (a.length+b.length)/2
Bhaisaab 1hr
dekh kar toh dekhiye majah ayega
@@rohan7507 live dekh rha tha bruh
@@theuntoldtree okay
Vg
public static double findMedianSortedArrays(int[] arr1, int[] arr2) {
if (arr2.length < arr1.length) return findMedianSortedArrays(arr2, arr1);
int low = 0, high = arr1.length, n = arr1.length + arr2.length;
while (low = 0 && cut1 - 1 < arr1.length ? arr1[cut1 - 1] : Integer.MIN_VALUE;
int l2 = cut2 - 1 >= 0 && cut2 - 1 < arr2.length ? arr2[cut2 - 1] : Integer.MIN_VALUE;
int r1 = cut1 >= 0 && cut1 < arr1.length ? arr1[cut1] : Integer.MAX_VALUE;
int r2 = cut2 >= 0 && cut2 < arr2.length ? arr2[cut2] : Integer.MAX_VALUE;
if (l1
Why you saying 0+3/2 = 3 time is 48:29 minuts par
low---0, high is 3 low+high/2= 1.5
Ma'am not mam
test
very nice explanation
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.