Тёмный
No video :(

LeetCode Sort List Explained - Java 

Nick White
Подписаться 379 тыс.
Просмотров 79 тыс.
50% 1

The Best Place To Learn Anything Coding Related - bit.ly/3MFZLIZ
Join my free exclusive community built to empower programmers! - www.skool.com/...
Preparing For Your Coding Interviews? Use These Resources
--------------------
(My Course) Data Structures & Algorithms for Coding Interviews - thedailybyte.d...
AlgoCademy - algocademy.com...
Daily Coding Interview Questions - bit.ly/3xw1Sqz
10% Off Of The Best Web Hosting! - hostinger.com/...
Follow Me on X/Twitter - x.com/nickwhit...
Follow My Instagram - / nickwwhite
Other Social Media
----------------------------------------------
Discord - / discord
Twitch - / nickwhitettv
TikTok - / nickwhitetiktok
LinkedIn - / nicholas-w-white
Show Support
------------------------------------------------------------------------------
Patreon - / nick_white
PayPal - paypal.me/nick....
Become A Member - / @nickwhite
#coding #programming #softwareengineering

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

 

23 фев 2019

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 115   
@iphoneeating
@iphoneeating 4 года назад
Just a suggestion, you will know better. For future videos could you please move your face box to the left of the recording. You write code on the right side and sometimes it hides behind your face box. I really enjoy your videos and they are really helping me in improving my DS & Algos. Keep up the good work
@NickWhite
@NickWhite 4 года назад
IPhone Apple thanks! And yeah I’ve realized that and I changed it in my newer videos
@farazhusain925
@farazhusain925 4 года назад
I'm also facing the same issue
@rahulojha6500
@rahulojha6500 3 года назад
I'm also facing the same problem....
@PriyaSingh-du4xc
@PriyaSingh-du4xc 4 года назад
I have been stuck with this problem since 2 days and your 9 minute video made it so simple and easy. Your 3rd attempt might be painful but it was totally worth it for me. Thanks a lot.
@playstationgaminghub4124
@playstationgaminghub4124 3 года назад
Everything was amazing till @5:09
@96merluzzo
@96merluzzo 3 года назад
The energy you put in your intro is incredible
@iamjiaji
@iamjiaji 4 года назад
Excellent explanation, thanks Nick. One thing need to point it out is per the question, it requires "constant space complexity. ", but the space complexity for your solution is O(Log(n)) which is the recursion depth.
@bharathateja2797
@bharathateja2797 5 лет назад
very nice explanation. i think l1 = l1. next , l2 = l2.next is not needed in last two if statements
@felixjesussolanovergara2553
@felixjesussolanovergara2553 5 лет назад
maybe he wants to put while instead
@iwontigers6092
@iwontigers6092 3 года назад
I agree. a and b are not used afterwards, so it's pointless to move the pointer. A while loop is also not needed as a & b will never be off more in length than 1, since we split in halves.
@trinath6941
@trinath6941 3 года назад
How much time have you practiced to reach this level in coding? you are just rocking and making things very simple
@ZhouHaibo
@ZhouHaibo 3 года назад
Thanks, I was asked merge sort concept in an interview in 2020. And I didn't know about it at that time, then I start to improve my algorithm skill day after day. Your video is good and real man, we could see your fault and finding the faulty, though there is no digram for illustrated.
@honey-xr5kp
@honey-xr5kp 4 месяца назад
"Hopefully my face isn't blocking any of this" as it blocks everything he's typing lol
@AolaDIY
@AolaDIY 4 года назад
Dude ~ why your handsome face on top of your code? Dang!! no one else explains it better than you.
@shivambhardwaj3273
@shivambhardwaj3273 2 года назад
i was struggling understanding that split of left and right from 2 days. You earned my respect and a sub!
@juanperusquia7456
@juanperusquia7456 4 года назад
Nice channel for seeking help in leet code problems, suscribed! :)
@abhaypatil2000
@abhaypatil2000 3 года назад
sorry but this solution is not the expected answer. Constant space means without using recurssion as well. They were expecting an iterative solution.
@aronblanche
@aronblanche 7 месяцев назад
Ye agree
@zaeemashfaq4717
@zaeemashfaq4717 2 года назад
But isn't the space complexity O(log n) and not constant? The depth of the recursion is log n and hence the O(log n) space will be taken up by the call stack?
@tchen8124
@tchen8124 4 года назад
Amazing explanation. But, you are blocking the code, dude.
@NickWhite
@NickWhite 4 года назад
my bad :(
@harrymuir6625
@harrymuir6625 4 года назад
Hopefully, I won't be the only one who feels just like stuck when is about data structures and algorithms I mean when watching this kind of videos xD
@ophir1982
@ophir1982 4 года назад
Thanks. But is that indeed constant space? B/C the starch trace would be considered O(n) space. This problem should have defined it as “in-place”...
@arishsheikh3000
@arishsheikh3000 Год назад
It 0(n) space
@nagalakshmi1385
@nagalakshmi1385 4 года назад
very good video, merge sort in arrays the algorithm I knew had O(n) space, and I always like QuickSort over MergeSort for implementation, now I like mergeSort over QuickSort, thanks for making this video
@GyroZeppli-mi7xb
@GyroZeppli-mi7xb 2 месяца назад
did l1.next= null and l2.null=null in the first and Do we need to write it, and what is its role ?
@zilinli187
@zilinli187 4 года назад
Nice explanation! It's merge sort top-down version. However this question ask for constant space complexity, we should implement down-top version.
@shubhamrane2918
@shubhamrane2918 2 года назад
Can you please do a quickSort version as well. Thanks!
@unmeshkadam4876
@unmeshkadam4876 Год назад
Hi nick, first of all i want to thank you for providing such a quality content on RU-vid, it's really helping me improve, I am having my campus interviews starting after 15 days from now, can you please suggest me how I can gain maximum from this 15 days?
@sophiezhang6516
@sophiezhang6516 4 года назад
do you have the code somewhere? i can't follow the second part coz the code was blocked :(
@thefelixgan
@thefelixgan 3 года назад
Hi Nick, great explanation, but merge sort is O(n) space complexity, rather than O(1) as specified in the question. Is there an updated explanation where a different sort, preferable one with O(n) space, is used?
@letsdoit0298
@letsdoit0298 2 года назад
That is the case for arrays, but since this is a linked list we are storing only the start and end pointers (not the entire halves of the list), so it is O(1), I think.
@letsdoit0298
@letsdoit0298 2 года назад
Just a correction, since this is a recursion, O(logn) space will still be required for the recursion stack, but no additional space is required to store the list, as we are only using pointers here.
@olivejuice1985
@olivejuice1985 4 года назад
Dude looks tired as hell:(
@ajourney179
@ajourney179 4 года назад
amazing explanation. great. subscribed.
@NickWhite
@NickWhite 4 года назад
thanks!
@sephycai
@sephycai 5 лет назад
Please correct me if I'm wrong but this seems like O(logn) space complexity.
@NickWhite
@NickWhite 5 лет назад
logn isn't possible for sorting
@sephycai
@sephycai 5 лет назад
@@NickWhite Just want to clear the confusion first that I'm referring to space complexity. Since the "SortList" function is recursively called. It looks like O(logn) space instead of O(1) space.
@NickWhite
@NickWhite 5 лет назад
Raiden oh yeah if that’s what you’re talking about you’re right my bad if I said O(1) in the vid
@sephycai
@sephycai 5 лет назад
@@NickWhite yeah I'm trying to find some good explanation of constant space on RU-vid since the problem asked for it. I did see people posting their code but couldn't understand...
@jm.101
@jm.101 Год назад
I can't believe how much faster Java is than Ruby. This was the only Java solution that made sense to me as a Ruby developer. I translated this to Ruby and it ran at 79ms. Yours ran at 3ms. Wow.
@personalvaibhav4816
@personalvaibhav4816 2 года назад
Thanks man these videos help a lot
@marcushines4172
@marcushines4172 4 года назад
Merge sort is not constant space complexity, which the problem specifically calls for. You’ve failed the interview by ignoring requirements, but at least you know merge sort.
@NickWhite
@NickWhite 4 года назад
bye bye hater i flood the club with paper
@nikostrongioglou9941
@nikostrongioglou9941 3 года назад
What you're saying about the fast pointer though is not entirely right. The fast pointer will either point to the last node of the list (fast.next==null) or to null (fast==null). This does not really change the solution since we do not really care about the last node but just for clarification.
@michaeldang8189
@michaeldang8189 4 года назад
6:52 Yes it is :)
@milankushwah6391
@milankushwah6391 4 года назад
Really well explained. Keep it up bro!
@namanjain9922
@namanjain9922 3 года назад
please keep your image some other place code is not visible
@oyunboldganbold
@oyunboldganbold 3 года назад
Thanks Nick, you're great!
@yinongzhang7800
@yinongzhang7800 4 года назад
I don't think using recursion is O(1) space
@zilinli187
@zilinli187 4 года назад
Yes, its O(logn)
@tawhidshahrior8804
@tawhidshahrior8804 3 года назад
Love the work you do!
@anilgontla123
@anilgontla123 4 года назад
nicely explained
@dumbguy1073
@dumbguy1073 2 года назад
i dont understand why we are returning sorted_temp and how all values are getting added to sorted_temp list?????????????????????????????????
@suhasnayak4704
@suhasnayak4704 4 года назад
Good one, thanks!
@DEEPAKGOYALnullRA
@DEEPAKGOYALnullRA 4 года назад
great solution thanks
@xinyuanliu1959
@xinyuanliu1959 3 года назад
Can you please make a video of the O(1) method.
@AkramDevTalks
@AkramDevTalks Год назад
I think this takes log(N) space for the recursion tree
@user-oy4kf5wr8l
@user-oy4kf5wr8l 3 года назад
nice job buddy! thank you
@SK-lu7ci
@SK-lu7ci 4 года назад
Awesome explanation.....
@ogsconnect1312
@ogsconnect1312 4 года назад
Well done! Thanks
@prateeksinghal630
@prateeksinghal630 4 года назад
Awesome Video!! Please start making leetcode videos again!!
@rupaldesai7098
@rupaldesai7098 5 лет назад
I am not able to view the code as the video is covering the lower-right corner
@NickWhite
@NickWhite 5 лет назад
Rupal Desai sorry I’ve improved that in my newer videos
@rupaldesai7098
@rupaldesai7098 5 лет назад
@@NickWhite Thankyou for uploading the videos...it's a great help :)
@shaurya478
@shaurya478 3 года назад
great explanation
@chaoschao9432
@chaoschao9432 4 года назад
What is the usage of "temp" node?
@0215story
@0215story 3 года назад
I also would like to ask it ...
@unknownman1
@unknownman1 3 года назад
@@0215story to half the list
@tanieadas
@tanieadas 2 года назад
Disconnect the list from middle
@akanshkumar2876
@akanshkumar2876 3 года назад
this is your best video so far :-P
@AinasDiaries
@AinasDiaries 2 года назад
This guy always seems high to me ! ;)))
@devakinandan23
@devakinandan23 Год назад
please provide code for your videos
@KnowledgeHubAndMotivation
@KnowledgeHubAndMotivation 5 лет назад
while(l1!=null) and while(l2!=null) instead of if condition
@theUneditedNature
@theUneditedNature 4 года назад
if condition works here well because here we are dealing with connected list nodes
@mrigankchugh2096
@mrigankchugh2096 4 года назад
Great Explanation! Thanks.
@prashantkumar-ek3im
@prashantkumar-ek3im 2 года назад
100th comment!! great job ..nice code Thanks.
@SugamMaheshwari
@SugamMaheshwari 4 года назад
Good work soldier !!!!
@GLAKJack
@GLAKJack 3 года назад
Man looks like he hasnt slept in a week!
@priyakolluru356
@priyakolluru356 3 года назад
why merge sort? why not something else?
@ytann
@ytann 4 года назад
Man, you forgot to clap at the beginning of the video. : p
@CodeSuccessChronicle
@CodeSuccessChronicle 3 года назад
😹
@thelo-fispot7273
@thelo-fispot7273 Год назад
Bro your solution took 3ms but my solution with exact same code took 20 ms. Why is that?
@shunleungchan7375
@shunleungchan7375 3 года назад
pretty clear!
@Gaaravify
@Gaaravify 2 года назад
Good job
@aayushsarna6017
@aayushsarna6017 4 года назад
Can you share your code?
@andreyka26_se
@andreyka26_se 2 года назад
its O(n) memory
@shwetadk1986
@shwetadk1986 5 лет назад
Hey Nick. Good explanation. I have a question though. How will the sortlist function take care of even list ?. Lets say there are 4 elements, 4->2->1->3. If fast and slow both point to head, slow = 2, fast = 1. In the next go, slow will be 1 and fast will be NULL. How does this work ?
@shreyasingh1258
@shreyasingh1258 4 года назад
yes you are right bt then temp will be at 2 and he breaks the list at 2.and our newhead for second list becomes 1
@suhasjvrundavan3614
@suhasjvrundavan3614 2 года назад
dude your face is covering the program what can we see can't you check before uploading
@AngadSingh97
@AngadSingh97 4 года назад
Really well explained. I'm sorry you had to make the video thrice though :/
@honey-xr5kp
@honey-xr5kp 4 месяца назад
video starts at 0:42
@xypq8310
@xypq8310 3 года назад
can someone post solution ?
@arthurh2064
@arthurh2064 4 года назад
The video is great, but it bugs me that you're ignoring the space constraint (or maybe you simply weren't aware that recursive calls also take up space)
@babumon5351
@babumon5351 5 лет назад
Really nice.. Thanks
@raunaqsingh6472
@raunaqsingh6472 4 года назад
This is not using constant space time complexity.
@shrey6356
@shrey6356 4 года назад
Sleepy but good!!😍😆😍
@tanishktripathi8773
@tanishktripathi8773 3 года назад
God! I miss that clap
@praveenchouhan6388
@praveenchouhan6388 4 года назад
nice explaination but please try to create a visual approach first and then jump to the code, that will make this 5 times effective for others to get the intuitions of the approach and learn faster!!!!!!, and make sure ur webcam face position does not comes on ur code!!!!!!! thanks good work
@vk1618
@vk1618 4 года назад
Check other solution
@shubhamtiwari5671
@shubhamtiwari5671 4 года назад
great!
@WowPlusWow
@WowPlusWow 3 года назад
This is not constant space.
@xarakus
@xarakus 3 года назад
would have been a good video but for half of the video couldn't see the code.
@treyquattro
@treyquattro 4 года назад
to mergesort a linked list first split it into halves and halve-nots...
@beatx2173
@beatx2173 11 месяцев назад
Cooooooooooool
@soumyajitdutta9884
@soumyajitdutta9884 2 года назад
This fucking question is absolutely depressing
@tekken1935
@tekken1935 3 года назад
Move Nick.head
@nos44-
@nos44- 2 года назад
READ THIS : 😶 I was solving the daily challenge question on leet ... and todays question was this SORT LIST .. and now look at the date the video was uploaded and me here watching this .. exactly 3 years later 25th feb 2022
@MaminaZvezdochka
@MaminaZvezdochka 3 года назад
@shivamk843
@shivamk843 Год назад
why am i getting time limit exceeded with the same code 🥲🥲
Далее
Sort List - Merge Sort - Leetcode 148
13:17
Просмотров 70 тыс.
Self Taught Programmers... Listen Up.
11:21
Просмотров 1 млн
Insane Coffee trick EXPOSED 😱☕️ #shorts
00:20
Просмотров 3,7 млн
LeetCode 146. LRU Cache (Algorithm Explained)
18:00
Просмотров 117 тыс.
LeetCode Spiral Matrix Solution Explained - Java
11:07
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
LeetCode Reorder List Solution Explained - Java
12:55
A Jr Dev For Life?? | Prime Reacts
21:33
Просмотров 291 тыс.
LeetCode 36. Valid Sudoku (Algorithm Explained)
11:33
From React To HTMX
40:01
Просмотров 319 тыс.
Sorting Algorithms Explained Visually
9:01
Просмотров 527 тыс.