Тёмный

Median of two sorted arrays 

techsith
Подписаться 148 тыс.
Просмотров 17 тыс.
50% 1

Leetcode solutions JavaScript | Hard Question | find Median of two sorted arrays in O(m+n)
#algorithms #leetcode #interviewQuestions
*Code
codepen.io/techsithcode/pen/K...
*My Courses
www.learn.heapskills.com/cour...
www.learn.heapskills.com/cour...
Follow me
* / techsith
* / algoanddsinjavascript
* / techsith
* / techsith1
* / 13677140
* / patelhemil
Help me translate this video.
* ru-vid.com_cs_...
Note: use translate.google.com/ to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.

Наука

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 54   
@AARVINDHBEE
@AARVINDHBEE 3 года назад
Your solution is O(N + M) but in question they what O(log(N+M))
@Techsithtube
@Techsithtube 3 года назад
I will create another video for lo(n+n) I was going to do it but then I thought lot of people need bit more linear way.
@anshulverma6251
@anshulverma6251 3 года назад
It would be great if you make a video on Heap data structure. Please it's a request.
@mohammednishad4055
@mohammednishad4055 3 года назад
@@Techsithtube yes your solution is easy for beginners, thank you upload more videos
@ankitsoni3388
@ankitsoni3388 3 года назад
But as per the question, space complexity required was o(log(m+n)) but you did it in o(m+n)
@Techsithtube
@Techsithtube 3 года назад
I am going to create another video to cover o(log(m+n) ) the video was bit longer so I am going to split into two.
@vidhyalongani6521
@vidhyalongani6521 3 года назад
Hey.. I landed an offer for a Senior Frontend Developer position last week.. All thanks to your super useful videos.. thanks a ton.. U keep going n i wish u reach great heights
@Techsithtube
@Techsithtube 3 года назад
Great. Congratulations! I wish you best luck on your new endeavor. keep on learning!
@manuelnicolasaceituno4475
@manuelnicolasaceituno4475 3 года назад
Great vid!
@gsb22
@gsb22 3 года назад
tbh, you only need to while i+j
@Techsithtube
@Techsithtube 3 года назад
thanks for the input. I was thinking about that but , lot of the audience is new to algo so for them I thought of giving little bit clarity. I am in the process of making the video for O(log(m+n)) and space complexity O(1) . Will release that next.
@Itsnewstyle
@Itsnewstyle 3 года назад
new technique I learned...thanks :)
@ManishKhanchandani74
@ManishKhanchandani74 3 года назад
Nice
@Techsithtube
@Techsithtube 3 года назад
Thanks for watching!
@mahendrakulkarni1036
@mahendrakulkarni1036 3 года назад
Love your explanation technique...
@ScaleCodingSkills
@ScaleCodingSkills Год назад
I looked your code and the complexity of the merged approach is also O(Max(M,N)), not log(m+n)
@sethukunju
@sethukunju Год назад
yes that is true
@6b14yeungsinchun-8
@6b14yeungsinchun-8 3 года назад
Merging takes O(m + n)... log (n + m) is a lot harder than this...
@Techsithtube
@Techsithtube 3 года назад
I will create another video for lo(n+n) I was going to do it but then I thought lot of people need bit more linear way.
@rutabega306
@rutabega306 2 года назад
@@Techsithtube figure it out yet?
@Imgahlot
@Imgahlot 3 года назад
Really nice explanation .... Keep sharing knowledge with us...👍
@Techsithtube
@Techsithtube 3 года назад
I will try my best
@chandandy4919
@chandandy4919 3 года назад
@@Techsithtube is the second solution provided not O(m+n) ? I think u shud also provide explanation on time complexity.
@techbhupi9398
@techbhupi9398 3 года назад
Please don't stop ... just continue this series as long as possible & I will keep commenting ,like & share ON.THANX A TON SIR
@Techsithtube
@Techsithtube 3 года назад
Don't worry! I will keep making such videos. Thanks for watching!
@RajwinderKaur-po2qd
@RajwinderKaur-po2qd 3 года назад
Thanks... really helpful
@nativeKar
@nativeKar 3 года назад
Sir, I'm not sure why the multiple 'while' loop approach? The first one - the Brute force one - felt far more easier and it's so much more easier with JS.
@Techsithtube
@Techsithtube 3 года назад
You can also do it in one loop however for a video like this its easier to show whats going on in two multiple loops. I think complexity remain the same , its just code is bit more readable for novice.
@nativeKar
@nativeKar 3 года назад
Got it! Thanks for the reply.
@aman.tyagi112
@aman.tyagi112 3 года назад
❤️❤️❤️❤️❤️❤️❤️
@pulga961
@pulga961 3 года назад
last time i was this early you teached react
@Techsithtube
@Techsithtube 3 года назад
I am also planning for making more react videos. this is in plans. Thanks for watching!
@rutvikghori2410
@rutvikghori2410 3 года назад
@@Techsithtube but continued to coding as well, I request you
@Harchit23
@Harchit23 3 года назад
are you only gonna cover the frequent questions?
@sadanandnb6626
@sadanandnb6626 3 года назад
Sir.. Do u have another channel..in the name of InterviewNest??
@youngbinpaek8560
@youngbinpaek8560 3 года назад
At 8:31 shouldn't his return statement be totalArray.length%2, not totalArray%2, because we want to see if the array length is odd or even for the ternary operator? I'm not a high level coder by any means, i need confirmation cause I keep getting a different answer other than 2.5. Thank You in ADV.
@Techsithtube
@Techsithtube 3 года назад
You are right. I think I made a mistake in hurry. it should be totalArray.length%2. I am surprised that you are the first one to point this out. Thank you!
@himanshubansal6425
@himanshubansal6425 3 года назад
Please share more leetcode problem
@Techsithtube
@Techsithtube 3 года назад
Himanshu, my plan is to make more such videos. thanks.
@himanshubansal6425
@himanshubansal6425 3 года назад
@@Techsithtube please try to upload at least one leetcode problem in a week.
@himanshubansal6425
@himanshubansal6425 3 года назад
@techsith please upload more leetcode problem
@0lgatron
@0lgatron 2 года назад
The brute force method has an error -> it's supposed to be : return middle % 2 !== 0 ? (totalArray[middle] + totalArray[middle -1]) / 2 : totalArray[middle]
@varshankchoudhary6198
@varshankchoudhary6198 3 года назад
Thanks :) for your efforts for providing such type of easily understandable content. I go through a lot of content on RU-vid but my finding get completed when I found your channel. In my life all the front-end knowledge and all the interviews which I cleared was because of your efforts. Thanks a lot!!! keep going (y) ...Best Wishes!!!
@mangadd1836
@mangadd1836 2 года назад
I just started on js and found your channel. It really helps thanks a ton. 👍🏻
@arkadiuszmosio9793
@arkadiuszmosio9793 3 года назад
If I understand it correctly You do not have to merged full m+n length array. You just have to determined what is on floor((m+n)/2) position and return it value (or for even length return (floor((m+n)/2)+floor((m+n+1)/2))/2) )
@rauanamangeldiyev7881
@rauanamangeldiyev7881 2 года назад
The solution is not correct in terms of time complexity. In video it is O(m+n), whereas task requires O(log(m+n))
@nipunjain1142
@nipunjain1142 3 года назад
Hi Sir, Please provide more solutions in javascript, it's really helpful
3 года назад
2+4/2 is not 3. You're missing parenthesis.
@Techsithtube
@Techsithtube 3 года назад
its not part of the code. I was just explaining the logic . So didnt have to make it perfect. :)
@tusharjajodia9077
@tusharjajodia9077 3 года назад
Completed Waste my time watching O(N + M) solution
@SuccessWheels
@SuccessWheels Год назад
This is not the leetcode solution because its asking to solve with O(log(m+n)), not O(m+n). Sorry, but you got incorrect answer.
@1084kmp
@1084kmp Год назад
How is this an O(log(m+n)) solution? Instead this is a O(m+n) solution! You will have to find the median of the 2 arrays without creating a single sorted array in order to achieve O(log(m+n))
Далее
Median of 2 sorted arrays
26:38
Просмотров 3,8 тыс.
The Worlds Most Powerfull Batteries !
00:48
Просмотров 11 млн
Leetcode Two Sum Solution |  Coding Interview Question
13:03
top 10 JavaScript tricks
17:18
Просмотров 19 тыс.
stack implementation in JavaScript
21:55
Просмотров 4,2 тыс.
Throttling in JavaScript
8:13
Просмотров 29 тыс.
Индуктивность и дроссель.
1:00