LeetCode - Reverse Linked List Solution

  Рет қаралды 124,101

Nick White

Nick White

Күн бұрын

Пікірлер: 115
@eKizify
@eKizify 3 жыл бұрын
When you drew it in the end with the steps it just snapped in my brains and I ynderstood everything xd
@josephogoley
@josephogoley 3 жыл бұрын
Same!
@LongLe-ri5hs
@LongLe-ri5hs 3 жыл бұрын
Me too
@curtism7302
@curtism7302 4 жыл бұрын
Watched the whiteboard explanation 2 times , went back and looked at what next_node was equal to (i forgot) watched the whiteboard explanation a 3rd time and understood it! Watched it a 4th time and realized he was making perfect sense in his explanation. Nick, Just found your videos today through Kevin Naughton (who I also found today) Thanks for making these videos.
@Bad1tude
@Bad1tude 2 жыл бұрын
so basically you were in recursion
@vijayaprabhakaranr5478
@vijayaprabhakaranr5478 2 жыл бұрын
@@Bad1tude he was iterative for the number of mistakes in the code.
@GagandeepSingh-lz5bg
@GagandeepSingh-lz5bg 3 жыл бұрын
Your explanation is much easier to understand than the other youtube videos I have watched on this topic. Thank you.
@soumyadeepmitra811
@soumyadeepmitra811 4 жыл бұрын
Had to watch it a couple of times to understand but at the end it was crystal clear. Thanks Nick !!!
@toastyshrimp1882
@toastyshrimp1882 2 жыл бұрын
A good way to think about this, is you're flipping the pointers. Instead of each node pointing to their next node, you flip them to point to the node before, instead of 1 pointing to 2, 2 points to 1. You start this chain by first setting a new "head" node, to be a new node that comes before the head node.
@icemotion1925
@icemotion1925 3 жыл бұрын
I was struggling for hours before watching this video, thank you very much! Your drawing at the end triggered my Eureka effect.
@AliMalik-yt5ex
@AliMalik-yt5ex 2 жыл бұрын
By far the best explanation I have seen, the whiteboard visual is what helped! This is fantastic, Nick!
@merxgrc9940
@merxgrc9940 2 жыл бұрын
i like the fast pace and simple explanations for complicated topics really works for my adhd brain :)
@aaaminahammm4365
@aaaminahammm4365 2 жыл бұрын
Thank you so much nick, couldn't understand at first then i went back watched again did some copy work and got it
@nipunsandamal9882
@nipunsandamal9882 Жыл бұрын
This is the greatest explanation that I've found about reverse linked list
@ahmedaj2000
@ahmedaj2000 3 жыл бұрын
thanks for the visual on the whiteboard!
@letsplay9667
@letsplay9667 3 жыл бұрын
Please use white board for better understanding of solutions. It's really helpful.
@jacobl7451
@jacobl7451 3 жыл бұрын
this question is so famous, it's basically a meme
@coolengineering3486
@coolengineering3486 2 жыл бұрын
your way to explain makes sense in a way I can really understand. Thank you!!!!!
@pixel7038
@pixel7038 5 жыл бұрын
Techlead would be proud of you.
@TheKhalid1
@TheKhalid1 4 жыл бұрын
Whoop. This didn't age well
@markpascual100
@markpascual100 4 жыл бұрын
@@TheKhalid1 what happened
@datboi_gee
@datboi_gee 7 ай бұрын
lmao 5:16, the classic "you know what I'm sayin'?" Yes, I do believe I know what you're sayin'.
@alexirabor
@alexirabor 3 жыл бұрын
You are such a blessing. You saved me hours of confusion.
@colinrickels201
@colinrickels201 Жыл бұрын
Fav parts when you said, 'know what f this, lets do the whiteboard'. It is not easy to explain this one without visual representation. Its one those problems that an SWE with any experience has to revisit cause it will always be confusing.
@MrRobeezy29
@MrRobeezy29 2 жыл бұрын
Super clear when you see it drawn. Thank you 🙏
@lifeofme3172
@lifeofme3172 4 жыл бұрын
Thank you for the beautiful efficient solution I had to watch the video couple of times to understand 😂
@kelvincheung7272
@kelvincheung7272 4 жыл бұрын
always like your explanation, very clear and easy to understand
@daveB133
@daveB133 2 жыл бұрын
Thanks Nic. You've really helped me to understand this problem. One thing than confused me slightly was at 5 mins, you've got null > 1. I don't believe this link exists?
@tonyhiga8877
@tonyhiga8877 2 жыл бұрын
literally i'm watching this video ten times, kudos to your efforts.
@Kyle-ho4lj
@Kyle-ho4lj 4 жыл бұрын
Nick I would pay handsomely for more white board vids like tihs. you're a genius
@brie8861
@brie8861 3 жыл бұрын
Breehhhh!!! Thank you so much I was staring at this for forever trying to figure it . Seems so easy the way you explain
@ms0372631
@ms0372631 4 жыл бұрын
My only question is: null was never assigned pointed to head, how come you drew that on the board?
@raaghavaadithya
@raaghavaadithya 3 жыл бұрын
that arrow wasn't necessary, prob just a mistake!
@nigelgore5997
@nigelgore5997 2 жыл бұрын
3:21 It was at that moment i realized you are the Guru. 😁
@jugsma6676
@jugsma6676 4 жыл бұрын
Finally Nick White on White Board
@sowmyasg8127
@sowmyasg8127 4 жыл бұрын
thanks a lott for the explanation.. i understood very easy
@atuljain5539
@atuljain5539 3 жыл бұрын
thanks for good explanation .
@mdouet
@mdouet 3 жыл бұрын
If this more or less efficient than solving it with recursion?
@nirmalbhimani9033
@nirmalbhimani9033 2 жыл бұрын
Last explanation was amazing
@timurdosmurzayev6220
@timurdosmurzayev6220 3 жыл бұрын
Thank you, man! You did an awesome explanation
@AjaySingh-xd4nz
@AjaySingh-xd4nz 4 жыл бұрын
A "beautiful mind"
@sejinmajnaric2884
@sejinmajnaric2884 4 жыл бұрын
Such a great explanation! Thanks a lot!
@georgetiganila6667
@georgetiganila6667 3 жыл бұрын
Great demo on the whiteboard!
@griffinhealy200
@griffinhealy200 4 жыл бұрын
Thank you for the explanation!
@samm5571
@samm5571 3 жыл бұрын
I’m addicted to reversing linked lists
@dannyslebs6321
@dannyslebs6321 2 жыл бұрын
Thank you dude so clear!!
@nihardabhi5622
@nihardabhi5622 2 жыл бұрын
can we use stack and pop out from the end and each of these the connected with simple link ???
@OTT_Assassin
@OTT_Assassin 2 жыл бұрын
On the white board does prev change to two the first time?
@lookintomyeyes2681
@lookintomyeyes2681 4 жыл бұрын
just to add to the solution : you need to add start= pre after the end of all the loops
@ach952
@ach952 3 жыл бұрын
3:36 auto typing features omg 😄
@bruteforce2434
@bruteforce2434 2 жыл бұрын
Simple and efficient, thanks.
@prasadm3614
@prasadm3614 3 жыл бұрын
Do we really need head.next=prev assignment ..... I don't understand why. I think it works without
@blackraven6049
@blackraven6049 4 жыл бұрын
Are you a UB student or alumnus?
@salomeoumarouwate2024
@salomeoumarouwate2024 Жыл бұрын
Nick is just the GOAT!!!!
@aribbhai3343
@aribbhai3343 Жыл бұрын
damn bro I was gonna quit everything till I saw this video. Now I know how to reverse a linked list. I'm comin for u Google
@rohitparthasarathy6671
@rohitparthasarathy6671 3 жыл бұрын
Easy explanation - Thanks.
@rabihutomo1598
@rabihutomo1598 2 жыл бұрын
pls do more algo & data structure
@jamm9848
@jamm9848 3 жыл бұрын
Thank you it helped me 🙏
@Levelord92
@Levelord92 Жыл бұрын
I'm trying to understand this thing 2 days in a row, still my mind can't handle this.
@mannana8550
@mannana8550 3 жыл бұрын
'So do you wanna be a software engineer at google?' -- No, thank you Clement's girlfriend! Leave me alone
@zerlinazeng4064
@zerlinazeng4064 2 жыл бұрын
you are such a genius!!
@tej3679
@tej3679 3 жыл бұрын
Awesome explanation
@sagunpandit6314
@sagunpandit6314 3 жыл бұрын
recursively?
@crackcodinginterview4995
@crackcodinginterview4995 4 жыл бұрын
That’s a good one Nick!
@jkewara76
@jkewara76 3 жыл бұрын
great thank you from India
@arjay_2002
@arjay_2002 2 жыл бұрын
O(n) right?
@jaxconf9519
@jaxconf9519 3 жыл бұрын
OMG THANKYOU!! best video ever!!
@huythe3170
@huythe3170 2 жыл бұрын
Thanks
@abhirammadhu2973
@abhirammadhu2973 3 жыл бұрын
Can someone explain what happens on line 13, instead of ListNode prev = null; we write ListNode prev = new ListNode(); I did this on leetcode and I got an extra zero at the end of the output. How did this happen. What is the exact difference between the two??
@iuseyoutubealot
@iuseyoutubealot 2 жыл бұрын
this is a good question, do you know the answer to this now by any chance?, im curious
@shivam_sharma704
@shivam_sharma704 Жыл бұрын
thank you
@sameer9368
@sameer9368 3 жыл бұрын
Please make more such video
@sanyamkothari4469
@sanyamkothari4469 2 жыл бұрын
4:40 start from here and understand in 15 sec
@ForNoOne1
@ForNoOne1 4 жыл бұрын
Runtime 0ms?? What hacks are you using
@samuelmartinelli7730
@samuelmartinelli7730 2 жыл бұрын
If she doesn’t know how to reverse a linked list, I don’t want her.
@arpit8273
@arpit8273 4 жыл бұрын
why do we return prev?
@timothyclifford7288
@timothyclifford7288 4 жыл бұрын
prev ends up being the head because the while-loop runs until you shift the head to the last next value, which is Null
@justins7796
@justins7796 4 жыл бұрын
the main code is a function definition that needs to return a ListNode object ( at line 11)
@justins7796
@justins7796 4 жыл бұрын
could've returned any data type desired, for example public ListNode could have been a float or void if he'd wanted, but in this case it was most practical to return an object that is a linked list
@yudhisthirsingh8401
@yudhisthirsingh8401 4 жыл бұрын
Runtime 0ms, How is that possible? The parameters shown by leetcode looks like a prop to me sometimes.
@mdouet
@mdouet 3 жыл бұрын
It ran in under 1,000,000 nanoseconds.
@leaoverend7860
@leaoverend7860 4 жыл бұрын
when creating new ListNodes, when would you use the new keyword?
@nirmalbisht8297
@nirmalbisht8297 3 жыл бұрын
nope
@mdouet
@mdouet 3 жыл бұрын
No we just want a reference/pointer to the nodes, not a new instantiation of a node.
@daljeetsingh9736
@daljeetsingh9736 4 жыл бұрын
Hi ! Can you please explain to me how did you return prev; in the return statement? I would be highly grateful.
@yudhisthirsingh8401
@yudhisthirsingh8401 4 жыл бұрын
When the looping is done, prev points to null which is the start of the linked list (After modification).
@pt4909
@pt4909 2 жыл бұрын
You are a hero
@yuvrajbansal6294
@yuvrajbansal6294 4 жыл бұрын
Great job
@topG448
@topG448 3 жыл бұрын
Fellow Alumni... Go Bulls!
@sarscov9854
@sarscov9854 3 жыл бұрын
How the fuck can anyone pass those coding interviews without memorizing how to solve hundreds of problems?
@ChickenMaster7
@ChickenMaster7 2 жыл бұрын
That link list things are confusing af lol
@Salesforce_Nexus
@Salesforce_Nexus 4 жыл бұрын
good one!
@adityarajmane695
@adityarajmane695 3 жыл бұрын
low audio
@vlinkin22
@vlinkin22 2 жыл бұрын
Gold !
@GameFlife
@GameFlife Жыл бұрын
Hi Nick
@adityasinghrajawat7344
@adityasinghrajawat7344 4 жыл бұрын
You are just amazing.
@enderezjaroldadrian6865
@enderezjaroldadrian6865 3 жыл бұрын
I love you Nick
@Montclairsoccer1
@Montclairsoccer1 4 жыл бұрын
What a guy!
@udaychatterjee4424
@udaychatterjee4424 3 жыл бұрын
Dude no wonder you have more subscribers now. You used to explain way more than it’s needed. Lol
@xvzf115
@xvzf115 3 жыл бұрын
ok Mr. Expert
@KyuriousBot
@KyuriousBot 2 жыл бұрын
When you see it (:
@34adnanali26
@34adnanali26 2 жыл бұрын
wow
@Truthhurtsbad
@Truthhurtsbad 3 жыл бұрын
go bulls
@knajdovski
@knajdovski 3 жыл бұрын
Thanks for the clear explanation. P.S. you should go to bed
@devke125
@devke125 2 жыл бұрын
AWESOME 🖤🔥🖤🔥🖤
@tsaileslie8958
@tsaileslie8958 Жыл бұрын
You are really handsome and please make more videos😂❤
@Supersoaker-xy2cr
@Supersoaker-xy2cr 2 жыл бұрын
wooooooow i finally get it lmao
@tjray3403
@tjray3403 4 ай бұрын
W guy
@MaminaZvezdochka
@MaminaZvezdochka 3 жыл бұрын
@georgetsiklauri
@georgetsiklauri 4 жыл бұрын
Man, if you ever want to become teacher/trainer, please never explain concept like this. Your solution works, but the explanation should be for others, not that you understand what you talk.
@yudhisthirsingh8401
@yudhisthirsingh8401 4 жыл бұрын
I think it was well explained
@HanifCarroll
@HanifCarroll 4 жыл бұрын
Which part did you think could have been better explained? Or how do you think he could improve? If you would actually like him to improve his technique as a teacher, then he's going to have a hard time doing that when he doesn't know what exactly is wrong.
@ASMSADIQULISLAM
@ASMSADIQULISLAM 4 жыл бұрын
His explanation is clear. It's not necessary that we always explain first and code later.
LeetCode Reorder List Solution Explained - Java
12:55
Nick White
Рет қаралды 32 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 13 МЛН
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 77 МЛН
(16) Compiler foundations: Parsing (COP-3402 Fall 2024)
1:10:12
Self Taught Programmers... Listen Up.
11:21
Nick White
Рет қаралды 1,1 МЛН
I Got Rejected (again)
9:43
Nick White
Рет қаралды 205 М.
LeetCode Palindrome Linked List Solution Explained - Java
9:35
Nick White
Рет қаралды 112 М.
LeetCode Reverse Linked List II Solution Explained - Java
8:34
Nick White
Рет қаралды 36 М.
Coding Was Hard Until I Learned THESE 5 Things!
8:02
Nick White
Рет қаралды 31 М.
Samsung mocking Apple 😂💀 #blowup #apple #samsung #edit
0:31
skullmaxx
Рет қаралды 32 МЛН
Самый длинный айфон в мире!
0:20
По ту сторону Гугла
Рет қаралды 529 М.
Luminous screen protectors 🔥 #iphone ##screenprotector #android
0:19