LeetCode Tutorial 4. Median of Two Sorted Arrays

preview_player
Показать описание
GoodTecher LeetCode Tutorial 4. Median of Two Sorted Arrays (Java)

LeetCode Tutorial by GoodTecher. The tutorial provides a step-by-step demonstration on how to solve coding problems.

Complete Playlist for the GoodTecher LeetCode Tutorial:

GoodTecher Website:

GoodTecher Channel on YouTube:

GoodTecher Github:

GoodTecher Facebook

GoodTecher Twitter
Рекомендации по теме
Комментарии
Автор

这是我见过的最简洁的写法。。看了很多外国人用python, java, c, c++写的,真心都不如你这个简洁,厉害厉害

danli
Автор

Thanks for uploading this. It was so clear. Hope you load more videos

anssha
Автор

Your videos are very useful, I got this question in an actual interview and got stumped on how to solve it. I knew the O(n) solution and could not figure out the O (logn) solution

Garensonic
Автор

On line 27 and 28, when the index goes above the length of the array, why do you choose Integer.MAX_VALUE? Why not Integer.MIN_VALUE. Also when the index value goes out of range for an array, we have processed less than k/2 elements of that array. Therefore we cannot be sure that we have to find k-k/2 elements in the next iteration. We decrease k by k/2 only when we know that k/2 elements in A are smaller than k/2 elements in B. But if there are less than k/2 elements in A, we cannot do that. What am I missing here?

clyt
Автор

Thanks for the amazing video, but I need some help understanding the logic, Senpai! If there is no element in A, why is B[k-1] the median element?? For example if we have 3 numbers in A[1, 2, 3] and 7 numbers in B[4, 5, 6, 7, 8, 9, 10], When A becomes null, what is k of B?? how do we know B[k-1] is the median?

sarahswanson
Автор

I don't get the median for 2 not same size array is total/2 + 1. Can you explain me this?

LeoGoldenLabrador
Автор

I like your solution but your explanation is a bit hard to follow. Maybe its just a language thing.

MrWolfgangWeiss