Table of Contents: Me Talking 0:00 - 0:32 The Problem Introduction 0:32 - 1:43 Assessing What We Know 1:43 - 1:59 Finding Our Mental Barriers 1:59 - 4:09 The Hashtable Breakthrough 4:09 - 4:47 Linear Space Solution Walkthrough 4:47 - 9:33 Can We Do Better? :) 9:33 - 10:55 Constant Space Solution Walkthrough 10:55 - 16:46 Wrap Up 16:46 - 17:19 The code for this question is in the description. Both the linear space and constant space solutions are addressed.
@JT-yn4zk4 жыл бұрын
where exactly is the code? I can't seem to see it
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@rishabkumar49404 жыл бұрын
I just got placed in Amazon and I want to extend my deepest thanks to you. You helped me a lot man!! Thank you and all the best for your amazing channel
@dirkneuhauser82134 жыл бұрын
Finally someone who likes to explain stuff and who does it enthusiastically. It's a pleasure to watch! !! Thanks ma dud! :)
@BackToBackSWE4 жыл бұрын
great and sure
@paul-mw6pc6 жыл бұрын
great stuff, I didn't even understand the question being asked on the leetcode page. Your diagram helped a ton, thank you.
@BackToBackSWE6 жыл бұрын
sure
@MultiPriya285 жыл бұрын
You are the first teacher who has made me fall in love with DS.. I never thought I would ever dare to solve such kinda problems.. :D I started with quick sort and here I am.. Great explaination! And to all the followers : Just watch the video in fast forward mode.. !!!! ;D
@BackToBackSWE5 жыл бұрын
U a beast
@yanxichen42366 жыл бұрын
Well, I for one am glad you failed this question for that interview then... am I allowed to say that? lol Great video as always.
@BackToBackSWE6 жыл бұрын
haha
@batman_1st5 жыл бұрын
Ben's failure helped people like me, so thank you Ben, pls fail more haha!
@MiddleEasternInAmerica4 жыл бұрын
so far, that's my favorite video on BackToBackSWE channel, I smile everytime he says "again the code in the description" :)
@BackToBackSWE4 жыл бұрын
haha yeah we transitioned to website
@cryptojeff39934 жыл бұрын
This is awesome! Clear explanation. Lost my job offer because of coronavirus and preparing for interviews.
@BackToBackSWE4 жыл бұрын
Nice, contact us and we can give you a platform membership if you'd like
@tapasyak4292 жыл бұрын
I just found your channel and hands down this is THE BEST in terms of teaching how to solve a coding problem. Most of the videos I see just have the answer in hand and they try to explain how that answer works. But nobody tries to tell you how to come up with that answer ourselves first with common sense. This video exactly has what other's are lacking. On top of that, see that enthusiasm in that guy. I love him!
@vishnuvardhan6235 жыл бұрын
When I first saw the question,I thought it was just similar to clone graph and other thing is we should not mess up with original linked list pointers.But messing up with original linked list pointers gave the constant space solution😱.Awesome explaination!
@BackToBackSWE5 жыл бұрын
thx
@lugiadark214 жыл бұрын
When I first read the question I was like WTF I cannot solve this, after seeing your video I was able to code it without looking at the code. Thanks again!! Your videos are the best!!
@sanjanachopra21005 жыл бұрын
If not for this video, I wouldn't have understood the question itself. Thank you so much for all your videos☺️
@BackToBackSWE5 жыл бұрын
ye
@seungjinkim88605 жыл бұрын
A lot of questions I can't even understand what they're asking lol
@RitikSharma-pc5yj4 жыл бұрын
WOW!! Without this problem, the Linked list are incomplete :) Thanks for whatever you taught us
@BackToBackSWE4 жыл бұрын
sure
@osamaxz57206 ай бұрын
you are one of the best teachers, I solved it in O(n^2) and I don't watch your videos to see the solution as I really watch to see how to think, my thinking was near to yours but surly your is better and helped me a lot of learning how to think in more efficient way, thanks
@rishabkumar49404 жыл бұрын
I was asked this question in an interview today and I got it right just because of you!! Thanks man
@SumitKumar-fn3gj4 жыл бұрын
which company bro?
@BackToBackSWE4 жыл бұрын
great
@BackToBackSWE4 жыл бұрын
lol chil
@rishabkumar49404 жыл бұрын
@@SumitKumar-fn3gj Pensando Systems
@remykhayat57635 жыл бұрын
i spent hours trying to do this and even tho the constant space answer is non-trivial you made it very easy to understand, thank you sooo much, i hope i see this question in my next interview
@BackToBackSWE5 жыл бұрын
sure
@amospan142 жыл бұрын
Thank you for failing this interview question and instead of letting it define you as a failure, you used it as motivation to teach all of us. I appreciate it my man! =)
@yvestuyishime52095 жыл бұрын
If i get this question for the first time, i would cry!!!
@BackToBackSWE5 жыл бұрын
ye
@CrazyHunk145 жыл бұрын
to be really honest i just got stuck with the same problem in my interview. where i was about to discover the constant space solutions but i could not(interview pressure) then i came back to your channel and found out you too. now i am felling well about myself. still i am gonna binge all your videos thanks for helping you are doing a great job.
@BackToBackSWE5 жыл бұрын
thx
@ovoboyz15215 жыл бұрын
Thanks Ben, you always make complex problems easier to understand! Shoutout from Canada!
@BackToBackSWE5 жыл бұрын
hey
@mvm98886 жыл бұрын
Most detailed and effective teaching video I’ve ever seen on KZbin, thank u, already get used to watching your video when eating, wish I could also someday read my offer from twitter too!
@BackToBackSWE6 жыл бұрын
hahahahaha thank you. Food is very good.
@kuralamuthankathirvelan5 жыл бұрын
Perfect explanation bro ! Keep posting more videos !
@BackToBackSWE5 жыл бұрын
ok, on it
@Rendbot6 жыл бұрын
Thanks for all of your videos! Your video helped a lot. Got an offer from amazon!
@BackToBackSWE6 жыл бұрын
👀👀👀 Will u be in Seattle this summer?
@Rendbot6 жыл бұрын
My number one preference is Seattle. I get my official offer Tuesday.
@BackToBackSWE6 жыл бұрын
@@Rendbot ok
@Paradise-kv7fn5 жыл бұрын
from where did you prepare and how? I have just finished college and will be joining a tier 2 product based company but am planning to switch to the big 4 in the next year or so.
@tonybernoulli78595 жыл бұрын
This is far more clear than any tutorial I watched on youtube, please make more videos like this
@BackToBackSWE5 жыл бұрын
ok
@wishfulthinker61394 жыл бұрын
Explanation was soo good that i didn't even had to watch the code and was able to code it in one go...i subscribed at lightspeed.
@BackToBackSWE4 жыл бұрын
great and welcome
@Uniyaltech4 жыл бұрын
you are INCREADIBLE BEN.
@BackToBackSWE4 жыл бұрын
nah
@chengjiang70515 жыл бұрын
I have thought about a few minutes for the solution of constant space but in vain. When i saw you set the origin node's next pointer to the mirror node , I suddenly got the key point. hahaha Genius! Thx!
@BackToBackSWE5 жыл бұрын
nice haha, I didn't come up with it either, just learned from someone else
@shruthib33665 жыл бұрын
@@BackToBackSWE Love your modesty here!
@BackToBackSWE5 жыл бұрын
@@shruthib3366 it's tru
@waxylayer83534 жыл бұрын
Second approach is just great 💥 u r a genius !
@BackToBackSWE4 жыл бұрын
thanks!
@r1jsheth5 жыл бұрын
BIG thumbs up!! Loved the way you teach!
@BackToBackSWE5 жыл бұрын
thank you
@rajatverma16884 жыл бұрын
Not only I like the way he explains , i love the extra bit of fun he adds to the videos like *door opens ey* mixing tuschar roy videos in between .. fun content ben..
@BackToBackSWE4 жыл бұрын
lol thx
@darshandani12 жыл бұрын
Extremely well-explained ! Thank you for walking us over through the entire thought process. I had this question in an interview too and I failed to see all the small issues that you told in the video. Thanks !
@zihaoyan47412 жыл бұрын
This is way more intuitive than most sol on lc. Their algo makes sense but hard to implement when coding for me. your solution is much straight forward and I could come up with exact same answers just after viewing your video!
@dochaar5 жыл бұрын
Yet another amazing video Ben! This video might help so many other folks to get across the line at Google, can't thank you enough. Also, quick note, the url to the code doesn't work and seems to have updated since you added two new files into your GIT repo (constant space and linear space). Please update the links so it might help folks going forward :)
@BackToBackSWE5 жыл бұрын
got it thanks
@fannnatic4 жыл бұрын
awesome. thank you
@BackToBackSWE4 жыл бұрын
sure
@arbazshaikh44474 жыл бұрын
I can`t find the link for the code in description ?
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@alitherland7653 жыл бұрын
Where do I find the code? I cannot find it.
@heyjoe59202 ай бұрын
Man, thank you so much. Great explanation, especially of O(1) space solution.
@gamberril4 жыл бұрын
Very good explanation, thanks !
@BackToBackSWE4 жыл бұрын
sure
@kaustubhdwivedi17293 жыл бұрын
Can't get a better explanation 🤯
@gulshansingh39334 жыл бұрын
Awesome stuff dude
@BackToBackSWE4 жыл бұрын
ye
@meenameiss5 жыл бұрын
You're great at teaching, congratz. Keep going as long as you can
@BackToBackSWE5 жыл бұрын
thx
@SuprBrian644 жыл бұрын
Great Explanation!
@ankurgupta46964 жыл бұрын
Your are One of the best teachers on youtube , i learn so much from you
@BackToBackSWE4 жыл бұрын
I am but a man
@SarabjotSingh2943 жыл бұрын
Really amazing explanation!!!! Thanks!
@mohitbhatia1994h5 жыл бұрын
Great and elegant explanation.
@BackToBackSWE5 жыл бұрын
thanks
@ogetysaivamsi1064 жыл бұрын
Thank you for making it very simple to understand.
@BackToBackSWE4 жыл бұрын
sure
@kunqian065 жыл бұрын
Just awesome as usual. Bravo!
@BackToBackSWE5 жыл бұрын
thx
@Anveshana8375 жыл бұрын
Great video thanks
@BackToBackSWE5 жыл бұрын
sure
@mrivesingh5 жыл бұрын
You just made this really simple to understand! Thanks a ton!
@BackToBackSWE5 жыл бұрын
sure
@ciarlok7778Ай бұрын
Great explanation
@alexanderchao53893 жыл бұрын
This is such a beautiful explanation!
@prithazz4 жыл бұрын
You are an amazing teacher!
@BackToBackSWE4 жыл бұрын
thx
@shivanshrawat26884 жыл бұрын
Brilliant explanation. I have a small question if we are creating copies of N nodes how is this constant space?(the second approach) We have to create N more Nodes everytime, pardon me but i am a little confused.
@BackToBackSWE4 жыл бұрын
We often leave the space of the copied list out and only attest to the space allocation of the algorithm asymptotically (since the copy space usage is trivially understood). Either is common.
@shivanshrawat26884 жыл бұрын
@@BackToBackSWE So if create another list with N nodes or create N copies of all the nodes it wont increase space complexity? Space complexity will only increase if we use another data structure and add n items to it like a hash table or array or Map?
@@BackToBackSWE Haha back to the interview game and you come to my rescue
@BackToBackSWE5 жыл бұрын
@@cesare-o7l lmao, good luck
@Alex-wy2ko5 жыл бұрын
great video! lots of thanks!
@BackToBackSWE5 жыл бұрын
sure
@scodz20075 жыл бұрын
You ROCK bro, keep up the good work!
@BackToBackSWE5 жыл бұрын
u rock
@tapasu75145 жыл бұрын
Best Explanation Ever ! Thanks for all the great videos
@BackToBackSWE5 жыл бұрын
sure
@Metachief_X5 жыл бұрын
Great stuff dude!!!!
@BackToBackSWE5 жыл бұрын
thx
@abhishekkumarjaiswal15073 жыл бұрын
great explanation sir
@vivekgr30015 жыл бұрын
good explanation
@BackToBackSWE5 жыл бұрын
sure
@subhangijena43814 жыл бұрын
Best explanation of this question.
@BackToBackSWE4 жыл бұрын
ye
@sukritkapil25624 жыл бұрын
Just Wow! Thanks a lot!!
@BackToBackSWE4 жыл бұрын
sure
@veeralsharma67484 жыл бұрын
best explanation for this question out there
@BackToBackSWE4 жыл бұрын
thanks
@tewodroswolde98305 жыл бұрын
Thanks for posting Ben! Arif sira newu. Berta!
@BackToBackSWE5 жыл бұрын
Thanks
@Max-zf5ot5 жыл бұрын
You are an amazing teacher !!!!
@BackToBackSWE5 жыл бұрын
thanks
@KevinJohnMulligan2 жыл бұрын
From 5:51 you did a kind of stop frame animation thing with the video editing which was super satisfying to watch and the narration mapped perfectly too 👌
@CHIRANJIBNANDY15 жыл бұрын
I am little confused. Might be very trivial and a silly question to ask. Does not the constant space mean extra spaces/nodes we create in memory ? If that's the case we created / cloned all the nodes in the first pass of our constant space solution. Please correct me, what am I missing ?
@BackToBackSWE5 жыл бұрын
Yes, that is correct, but we are not counting the output space
@ankababuyou5 жыл бұрын
Link to code in the description is broken. Can you please look into that?
@BackToBackSWE5 жыл бұрын
ik
@cunghocthuattoan78694 жыл бұрын
I could not find the code in the description. Can someone help me?
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@davidj25975 жыл бұрын
Thanks man, you are so helpful
@BackToBackSWE5 жыл бұрын
sure
@shwetasharma-hz3ib4 жыл бұрын
thank you, you made it look so easyyyyyyy......
@BackToBackSWE4 жыл бұрын
ye
@shravyaramesh60405 жыл бұрын
This is beautiful and you are amazing.
@BackToBackSWE5 жыл бұрын
ur cool
@mahadreamz3 жыл бұрын
Great stuff. You said code is in the description. Where is it?
@gurleenkaur57865 жыл бұрын
Really great explanation and thanks for providing the code!!
@BackToBackSWE5 жыл бұрын
sure
@kaustubhchaturvedi6583 жыл бұрын
why is space complexity O(1) for the 2nd approach? We are declaring n new node containers for n existing nodes. So the auxiliary space will scale up as input size increases.
@indranilthakur36054 жыл бұрын
Where is the code in your description? I can't seem to find it.
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@j.c98585 жыл бұрын
Thank you for helping me out, it is the problem failed me in the most recent interview...could you please share the code again? seems the shared link has expired...appreciate!
@BackToBackSWE5 жыл бұрын
sure and ik
@priyankareddy74082 жыл бұрын
Love it! Thank you
@BackToBackSWE2 жыл бұрын
Thank You!! Do check out backtobackswe.com/platform/content and please recommend us to your family and friends :)
@goodwish15435 жыл бұрын
Wonderful. Good illustration, easy to understand. I found the solution similar to clone graph. And learned O(1) space solution, as you said, just for knowing it exists.
@goodwish15435 жыл бұрын
It only took me first couple minutes to understand each solution, very good teaching.
@BackToBackSWE5 жыл бұрын
ye
@xinyuyou75125 жыл бұрын
Really great explication. Thank you!
@BackToBackSWE5 жыл бұрын
sure
@priyankmungra294 жыл бұрын
great detailed explanation. Thank you sir for your efforts.❤❤❤
@illiakailli2 жыл бұрын
thanks for a nice explanation! I can definitely see an improvement over the hashtable version. The only thing that’s not clear is why last solution is ‘constant space’, when you had to create N clones in addition to the original array?
@Tasarran Жыл бұрын
That's the product that is being asked for, it is understood that at least that much space will be taken up. What he means is that it doesn't create any EXTRA space that would have to be garbage collected in some way.
@AmeyaKherodkar5 жыл бұрын
Very Nice Explaination (Y) and the efforts you take to make yours viewer understand (Y)
@BackToBackSWE5 жыл бұрын
thx
@uyennguyen-tw6kp5 жыл бұрын
thanks for your videos!!
@BackToBackSWE5 жыл бұрын
sure
@svdfxd6 жыл бұрын
Awesome explanation and beautiful way of rewiring nodes in the LinkedLists.
@BackToBackSWE6 жыл бұрын
indeed
@AbhishekSingh-fc6tb4 жыл бұрын
Brilliant way!
@BackToBackSWE4 жыл бұрын
ye
@snehalahire11944 жыл бұрын
This is such an amazing explanation . Where is the link to the code?
@BackToBackSWE4 жыл бұрын
The repository is deprecated, we only maintain backtobackswe.com now.
@mohinim.16544 жыл бұрын
Awesome video! It would be really helpful, if you could put code in either description or github.
@BackToBackSWE4 жыл бұрын
thanks and the repository is deprecated - we only maintian backtobackswe.com's solutions.
@ankugupta4135 жыл бұрын
This was so cool! Thanks
@BackToBackSWE5 жыл бұрын
thanks
@FirefoxGuy183 жыл бұрын
Thank you
@alperozdamar5174 жыл бұрын
Amazing solution. I liked it. Very easy to understand and implement. Thank you. :)
@BackToBackSWE4 жыл бұрын
sure
@dustinv91935 жыл бұрын
Subscribed. love you man :)
@BackToBackSWE5 жыл бұрын
love you too
@gokuljegan51204 жыл бұрын
Where the link for code in description?
@BackToBackSWE4 жыл бұрын
The repository is deprecated - we only maintain backtobackswe.com now.
@savar335 жыл бұрын
You are the man!
@BackToBackSWE5 жыл бұрын
no u
@steelcube5 жыл бұрын
Thanks for this!
@BackToBackSWE5 жыл бұрын
yeah sure
@agamdeepsingh16752 жыл бұрын
what if the node has duplicate values? Will the solution with mapping work?
@MithleshKumar-iz1dz5 жыл бұрын
Great, great, great!
@BackToBackSWE5 жыл бұрын
thanks
@cristianouzumaki24553 жыл бұрын
I have come here thrice for the same question, not because I didn't understand the question but because I keep forgetting this trick. Also his explanations are always very good .