Implement An LRU Cache - The LRU Cache Eviction Policy ("LRU Cache" on LeetCode)

  Рет қаралды 176,627

Back To Back SWE

Back To Back SWE

Күн бұрын

Пікірлер: 688
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Table of Contents: (I'm screaming in this video. I know. I am sorry.) Messing Around 0:00 - 0:23 Problem Introduction 0:23 - 0:36 What Does LRU (Least Recently Used) Mean? 0:36 - 1:10 Short Example of The LRU Policy 1:10 - 2:28 What Is A Cache? 2:28 - 2:53 What Is An LRU Cache? 2:53 - 3:12 The Properties of An LRU Cache 3:12 - 6:44 LRU Cache Operations Walkthrough 6:44 - 12:18 Summarizing The Ideas 12:18 - 12:53 More Subscriber Begging 12:53 - 13:12 Notes: 10:52 -> We need the nodes to hold their own keys. This matters when the LRU entry is evicted when capacity is surpassed. We just pop the item from the doubly linked list's end BUT I made the mistake to say the nodes won't need keys. They will need their respective key. We need the removed node's key to remove it from the hashtable since it is now out of the cache completely. Comments: Yes. I am screaming. I know. I messed up the first like 30 videos because I was still learning audio. The code is in the description. Note, we could also use Java's LinkedHashMap, but I choose to use this code example since it takes all that abstraction away so you see all of the critical operations that need to be taken care of if you were to really implement this.
@evanxg852000
@evanxg852000 5 жыл бұрын
It's ok to scream bro, it's just that passion driving you I guess. loving the channel.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@evanxg852000 hahahahha, nah, I just didn't have a mic
@michaelfekadu6116
@michaelfekadu6116 5 жыл бұрын
THANK YOU FOR SCREAMING! IT MADE LRU CACHE MAKE MORE SENSE! THIS VIDEO IS MORE MEMORABLE 😫😄
@toprank9602
@toprank9602 4 жыл бұрын
@@BackToBackSWE is this a system design question?
@asifbherani3490
@asifbherani3490 4 жыл бұрын
Such a nice explanation but very disappointing end to it as we dont have the code in description. Please update the video and description :(
@MostafaAliMansour
@MostafaAliMansour 5 жыл бұрын
This channel is underrated, dude u r really awesome !
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Let's increase the rating
@RohitKumar-so9ik
@RohitKumar-so9ik 5 жыл бұрын
Yup seriously this man is way more than what we predict through his subs!!
@srijaanand2793
@srijaanand2793 4 жыл бұрын
Cannot appreciate enough how well you explain the problem, and not just read out the problem statement and code! Sometimes just understanding the code is required but often I need an in-depth understanding of the question and what was the thought process etc. Whenever I come across a question like that, I just hope that you would have made a video on it and come to your channel :)
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure, and great to hear
@TKNinja007
@TKNinja007 2 жыл бұрын
Great video, I love how you spent the entire video breaking down the concepts instead of showing any code.
@BackToBackSWE
@BackToBackSWE 2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@maripaz5650
@maripaz5650 4 жыл бұрын
just answered this question yesterday in an interview, bless your channel. Thanks to you, I was able to stumble upon the optimal solution a lot quicker than if I was working on my own!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
great
@sddhrtha
@sddhrtha 5 жыл бұрын
I have my campus recruitment in a month, and your entire channel is on my revision list. Dude, I can't thank you enough for making these high-quality videos.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yw, go get the offer now! haha, u can do it
@zummotv1013
@zummotv1013 5 жыл бұрын
DataStructure and Algo group on WhatsApp.Please Join chat.whatsapp.com/GKVxU5dvU1e3v7h9ctDpXn
@ninja3514
@ninja3514 3 жыл бұрын
u Got a Job now?
@zahranajib5528
@zahranajib5528 3 жыл бұрын
Your energy and spirit is unmatched. Love ya man
@ANGELINK999
@ANGELINK999 5 жыл бұрын
I feel so lucky that I found your channel. Your videos are so easy to understand. You're awesome!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Thanks haha - shameless plug, releasing a course in 1-2 months - it'll be 🔥
@snowing906
@snowing906 5 жыл бұрын
Wow how is this channel so underrated. I feel like I found hidden treasure and I want others to also find it...
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Let's add to the treasure.
@kevin-lg3hs
@kevin-lg3hs 5 жыл бұрын
There's always a Back To Back SWE video to explain the leetcode problem that confused me. Thanks!!!!!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
haha
@zummotv1013
@zummotv1013 5 жыл бұрын
DataStructure and Algo group on WhatsApp.Please Join chat.whatsapp.com/GKVxU5dvU1e3v7h9ctDpXn
@giannizamora7247
@giannizamora7247 3 жыл бұрын
I'm about a month into my DS&A study and so many data structures and principles just clicked. Thank you for this!!!
@aditisaha99
@aditisaha99 5 жыл бұрын
Really great channel. The level of energy you have is insane. It motivates me more to put more energy to practice and prepare. very well explained and great content. you earned my subscription. Specially with the weather outside when you feel sleepy and dull and cant read more than a page, this is a must watch channel for anyone who is preparing for interviews in this season. Don't change your style :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
will do
@hihistorystory
@hihistorystory 6 ай бұрын
Been watching many tutorial resource these days. This is the best video. Wish I've seen this in the beginning and saved a lot of my time watching others.
@wadichemkhi
@wadichemkhi 5 жыл бұрын
insane level of energy
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
lol, old video, I was crazy. Still am.
@danni6113
@danni6113 5 жыл бұрын
This channel is so underrated. Great work!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
wassup
@shivakrishna7293
@shivakrishna7293 4 жыл бұрын
I think u r not an employee u r a perfect teacher i have seen very few people like you sir awesome
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
ok lol
@EcheChanga
@EcheChanga 3 жыл бұрын
Didn't understand this problem until I watched n I been looking at it for days Bless you brother.....and the energy made this so dope
@abcdeereijgfhd3215
@abcdeereijgfhd3215 2 жыл бұрын
Holy shoot~! I 've never thought about a double-linked list on this. Thank you for your clarification.
@amansinhparmar3336
@amansinhparmar3336 4 жыл бұрын
Thanks man, i literally spent 3 hours on this and finally get after watching this
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
excellent!
@LetsBeHuman
@LetsBeHuman 5 жыл бұрын
@10:42 - Anytime we interact with the node, it moves to the front of the list. So, lets say we are going to update (that is, put( ) ) 4,10 as 4,20. Shouldn't it take O(n) to traverse the doubly linked list and find where 4 is? each time when we update an existing item in the list, what is the big O for searching that element? By the way, you are welcome to our home for delicious food.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Hahahahahahahaha. Thanks for the offer. And no, access is O(1). We have a hashtable mapping to the memory address of each node. This costs us more space (excluding the list itself) but that is fine since it improves access time.
@xxiinsanexx
@xxiinsanexx 3 жыл бұрын
very very well done. explanations on point. i was asked this question during an interview. got hash table but never remembered doubly linked list. now im quite sure im going to remember it for life. thanks once again mate!
@lings628
@lings628 5 жыл бұрын
Your channel is brilliant. I love it so much that I told all my friends about this channel. The clarity in your explanation filled with the energy and passion to teach is just fantastic 🙌
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@paulonteri
@paulonteri 4 жыл бұрын
The Greatest Explanation i've found... Please do more leeetcode.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@1point0tennis
@1point0tennis 5 жыл бұрын
I kept getting stuck on how the doubly linked list removal would be O(n) then it clicked when you helped me realize the HashTable value points to the nodes themselves.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yeah, the nodes have unique representations in memory and the hashtable maps those memory addresses.
@aayushvrshney
@aayushvrshney 4 жыл бұрын
Best LRU cache explanation on whole KZbin!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@keshavrastogi5005
@keshavrastogi5005 5 жыл бұрын
I have not seen such a great explanation and code. You are just awesome man. God bless you!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks, if you liked this join our class, I'll be doing more explanations like this there
@Ana-vx5vx
@Ana-vx5vx 4 жыл бұрын
You teach better than my professor. Thanks
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
ye
@sagarrajput7172
@sagarrajput7172 4 жыл бұрын
You are really good at what you do. It is rare to find genuine smartness and passion in same place. You should be proud of yourself. And yes humour makes it good too.🔥
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@kamaboko1
@kamaboko1 5 жыл бұрын
Dude, you're a rock star. An explanation that made sense.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
nice
@airysm
@airysm 5 жыл бұрын
Thank u for making this question seem way less scary lol
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
you are awesome.
@manishasharma2863
@manishasharma2863 5 жыл бұрын
I am your Fan! No one can explain this with such simplicity. Thanks a ton! :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@anssha2643
@anssha2643 5 жыл бұрын
You are the best at what you are doing. Love the way you explain and makes things so easy. Its kind of motivating to me. Looking forward to more of your videos. God bless you.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Thanks
@ananyaashrivastava2783
@ananyaashrivastava2783 4 жыл бұрын
Wow ! You made the Question little easy to me ,thanks.
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
great to hear
@jkmaksy
@jkmaksy 4 жыл бұрын
Jeez, having MS interview in two days and then this video comes up :)
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
lol, a prophecy it is
@DennisSmdFreefightTrainer
@DennisSmdFreefightTrainer 4 жыл бұрын
How did you prepare for your MS interview when you didn't even know this problem?
@lugiadark21
@lugiadark21 3 жыл бұрын
Bro your channel is underrated, your explanations are the best
@perlaz1166
@perlaz1166 5 жыл бұрын
The opening is really cute!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thnaks? lol, this was way back when no one watched this channel
@yasmineelezaby5197
@yasmineelezaby5197 2 жыл бұрын
WOW! that's the most clear and easy explanation for this problem. Thanks!
@cambeeler6374
@cambeeler6374 5 жыл бұрын
Thank you! The way you break-down the problem, and then explain your thinking, really helps me to identify the pattern and approach to thinking around the problem for myself. I really appreciate your investment of time and energy !
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@JoeWong81
@JoeWong81 5 жыл бұрын
I like your yelling bro it prevents me from falling asleep. nice explanation too
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
hahahaha ok
@FrootNinja
@FrootNinja 5 жыл бұрын
yea it really does help
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@FrootNinja haha ok
@keshavsethi1610
@keshavsethi1610 4 жыл бұрын
thanks, man one of the neatest and most crisp explanation's I have heard
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@seymour_videos
@seymour_videos 3 жыл бұрын
i legit love his videos because of his sheer excitement and enthusiasm
@riskyferyansyahpribadi6984
@riskyferyansyahpribadi6984 3 жыл бұрын
a very detailed explanation and easy to understand, thank you Back to Back SWE
@BurhanWani1
@BurhanWani1 5 жыл бұрын
Really liked your explanation. It might have also helped to explain how the hash table stores the address (or the objects in case of Object Oriented languages) of each node corresponding to a key. Good stuff overall.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yep
@FrootNinja
@FrootNinja 5 жыл бұрын
first video watched, the fact you left it at sooo i'm hungry then left was dope. smashed that like button and subbed
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
hha thx
@poojaguru2516
@poojaguru2516 5 жыл бұрын
Please make more videos Ben coz I'm just surviving by learning through Your videos!! Best explanation :) All of your videos are great! You are an inspiration :) keep doing more videos !! Thanks a ton!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
haha nice. I'm starting a class soon. I'll be making 3-4 vids a day w/ Chris Jereza. It'll be good.
@poojaguru2516
@poojaguru2516 5 жыл бұрын
Waiting 😋😋
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@poojaguru2516 haha
@bostonlights2749
@bostonlights2749 4 жыл бұрын
Can we just give a shout-out to the awesome intro
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
lol sorry - no one watched back then
@madhurapattekar5815
@madhurapattekar5815 5 жыл бұрын
Very nice video. Please do more videos on LeetCode Questions. It will be helpful. Thanks!!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Yeah, I have 250 scheduled as of now. Will take me over a year to do but we will see how far I get.
@wawwaw7063
@wawwaw7063 4 жыл бұрын
thank you for your video, I came across this problem today and I had no idea how to implement O(1) put method until I see this
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@TheRadistOne
@TheRadistOne 4 жыл бұрын
Thank you, my guy! This was so clear & I love the ENERGY!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@ganeshchandrameesala257
@ganeshchandrameesala257 3 жыл бұрын
@@BackToBackSWE where is the code, I couldn't find it in the description
@karankanojiya7672
@karankanojiya7672 4 жыл бұрын
Teaching is an art, certainly mastered by this man! Respect++
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@方宇凡-g4d
@方宇凡-g4d 5 жыл бұрын
Your videos are always the best, so clear, thank you~!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@doruwyl
@doruwyl 5 жыл бұрын
I appreciate a lot your dedication for explaining things to the other people. Well done!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@shantanushende6
@shantanushende6 3 жыл бұрын
8:40 explained why the left has the LRU and why the right has MRU. Said it before saying it again, legend!!
@shilinwang2958
@shilinwang2958 2 жыл бұрын
hash table & singly linked list! Thank you, the explanation is really clear.
@mrthelovepanda
@mrthelovepanda 5 жыл бұрын
You can remove a node from a singly linked list in constant time. void RemoveNode (Node N){ N.data = N.next.data; N.next = N.next.next; } Great video, though. Helped a lot.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yeah
@miry_sof
@miry_sof 5 жыл бұрын
Can you remove the last item?
@MrFTW1001
@MrFTW1001 5 жыл бұрын
But isn’t searching for the item not constant time ?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@miry_sof yeah
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@MrFTW1001searching would be O(n) time but if we over-write the node being deleted it can be done in O(1) time even for a single linked list. I'll cover that on the site I'm making: twitter.com/thebigoguide I didn't consider this when I made this video months ago
@FrootNinja
@FrootNinja 5 жыл бұрын
Your channel should have subs like josh fluke, tech lead, joma tech & cs dojo. You're amazing bro! like keep this format up please!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ok
@ravikanthreddy89
@ravikanthreddy89 5 жыл бұрын
insane energy levels !! and nice editing/tranisitions in the algo tracing out. Liked it.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
I had a bad mic, sorry
@ashleylove308
@ashleylove308 4 жыл бұрын
This intro is everything...Nice walkthrough += entertaining
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
ye
@ayushagrawal258
@ayushagrawal258 4 жыл бұрын
Man you made this problem look so easy 🔥🔥
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@yuxinshi2098
@yuxinshi2098 5 жыл бұрын
Really helpful! You made this question simple and easier to understand, love the graph!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Everything can be made clear with the proper instruction. I am trying to get better at teaching daily. It is very hard. Thank you for watching.
@xavierelon
@xavierelon 2 жыл бұрын
That intro had me dying 🤣 thanks for the amazing content as always
@nagamass
@nagamass 5 жыл бұрын
Excellent video. I think, if reached capacity, we need to delete node first before adding. This way, we won't be out of space allocated for Cache
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
If we reach capacity we eject the LRU item right? Why the first node if that is where the freshest item is inserted?
@nagamass
@nagamass 5 жыл бұрын
@@BackToBackSWE I feel, we can do eviction before adding new node if we reach limit. let say, limit 4, before adding 5th node, we can do eviction and add the node. but in video, we are adding 5th node then deleting node.
@nagamass
@nagamass 5 жыл бұрын
@@BackToBackSWE I feel, we can do eviction before adding new node if we reach limit. let say, limit 4, before adding 5th node, we can do eviction and add the node. but in video, we are adding 5th node then deleting node.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@nagamass We can do it in either order, the final state after removal is the same.
@sarahm5750
@sarahm5750 Жыл бұрын
Great video and insightful, also love your energy!!
@marlegagaming1274
@marlegagaming1274 5 жыл бұрын
You deserve more subscribers
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Thanks!
@ReneeSLiu-zx5tj
@ReneeSLiu-zx5tj 5 жыл бұрын
I appreciate your thought-process sharing!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@AShahabov
@AShahabov 3 жыл бұрын
Awesome LRU explanation!
@john_rambo_27098
@john_rambo_27098 5 жыл бұрын
I LOVED the starting...
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
haha I remember it
@pulkitagrawal5054
@pulkitagrawal5054 4 жыл бұрын
Wonderful Explanation !! Great work Dude !! Keep making such videos !
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@krishnapurohit3494
@krishnapurohit3494 5 жыл бұрын
You can delete in O(1) from singly linked list given the pointer to delete.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
yeah
@helloworld4475
@helloworld4475 5 жыл бұрын
Thanks, you have very good whiteboard skills.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@satheshbm92
@satheshbm92 5 жыл бұрын
Man you are the killer. Binge watching all videos :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Haha. Excellent. Learn. Grow. And dominate the interview.
@margeshpatel8456
@margeshpatel8456 4 жыл бұрын
Like the energy and enthusiasm for teaching. Keep up :)
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@architgoyal2336
@architgoyal2336 5 жыл бұрын
I am new to your channel and this is a great channel. Loved the enthusiasm. Subscribed
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thanks
@r1jsheth
@r1jsheth 5 жыл бұрын
This was one hell of explanation! Many thanks.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Haha sure
@humansofcrypto9746
@humansofcrypto9746 5 жыл бұрын
You can delete an item in a singly ll without knowing its previous node as well, just overwrite the data and the ptr from the next node and delete it.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Yeah that is true, there is just an edge case if you are deleting the last ndoe - correct? I haven't deeply thought about this.
@vijayj1997
@vijayj1997 4 жыл бұрын
Best explanation than many other youtubers If it possible can you explain manacher's algorithm ?
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
yes
@tashifhoda2414
@tashifhoda2414 4 жыл бұрын
Really nice explanation. I was able to implement it with STL on my own!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
great!!
@ok.google
@ok.google 3 жыл бұрын
Glad I've guessed implementation right
@Adam-tz6gk
@Adam-tz6gk 9 күн бұрын
Outstanding explanation thank you so much
@Siddarthathota
@Siddarthathota 5 жыл бұрын
Can you also create a video on HashMap Implementation. This video about LRU cache is one of the best explanation I came across.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
Yep, I had this in the pipeline until I started working on the website I'm making rn for the channel...you'll see it in 1-2 months
@sergebyusajabo2138
@sergebyusajabo2138 3 жыл бұрын
This is a really good explanation. Thank you.
@sumanthm4605
@sumanthm4605 3 жыл бұрын
I couldn't find the code in description.. Can somebody tell me where it is.. It's a bit urgent.
@xiaoruizhou694
@xiaoruizhou694 5 жыл бұрын
very clear explanation! Thank you sir.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
ye
@anupkulkarni1703
@anupkulkarni1703 5 жыл бұрын
Good Job Mate! Subscribed to the channel!
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
love.
@unanimous8510
@unanimous8510 Жыл бұрын
Once I watched the first 15 secs of this video I immediately smashed the like button lol
@LipsaSenapati
@LipsaSenapati 3 жыл бұрын
Thank you for the awesome explanation! Very energetic! Request: It will be very very helpful if you upload a video for the Priority Expiry Cache with python code (probably using 2 heaps and 2 hashmaps works well but I am trying to use an OrderedDict for better performance likely improvement from O(log n)->O(1))
@vm1662
@vm1662 5 жыл бұрын
Great explanation! Also, the code is very clear. Really appreciate it. :)
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure
@alvintan4900
@alvintan4900 5 жыл бұрын
When you use the get function such as get(3) in this video, i understand the 'get' lookup uses the hashtable which is O(1) to retrieve. However, isnt it worst case O(n) to go through the doubly linked list to find the value of 3 in the DLL because you need to traverse through the nodes and thus making overall time complexity of the retrieval to be O(n)?
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
the hashtable will give us O(1) lookup
@alvintan4900
@alvintan4900 5 жыл бұрын
@@BackToBackSWE in this same process, you have to move the 3 key into the head in the DLL, which is what I am referring to the time complexity
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@@alvintan4900 Ah, yes we have reference to the head node so we can grab that reference and wire the touched node to the front in O(1) time
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
@Lisa Jones I did dang chill 😨😨
@randomuser66438
@randomuser66438 5 жыл бұрын
@@BackToBackSWE You still didn't answer the question. If you want the least recently used value, you'll have to traverse the whole DLL to get the hash-table reference, regardless of bringing the node to the front afterwards. Doesn't this make the retrieval time O(n)?
@hz3600
@hz3600 3 жыл бұрын
love your energy, very engaging, and this was a very useful video. Thank you so much!
@amarajavijayakumar938
@amarajavijayakumar938 2 жыл бұрын
are u able to see the code on the description?
@MrLazini
@MrLazini Жыл бұрын
Very clear explanation, much appreciated :)
@BackToBackSWE
@BackToBackSWE Жыл бұрын
Thank you! Please enjoy a special code from us - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=MrLazini 🎉
@laminendy
@laminendy 4 жыл бұрын
That's an awesome explanation! Thank you!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure!
@rishabkumar4940
@rishabkumar4940 4 жыл бұрын
Thanks for explaining it so clearly, I was having a tough time understanding it as its solution is locked on Leetcode😅
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
great
@20041537
@20041537 4 жыл бұрын
easy to understand. well done!!!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thx
@kumarprateek1279
@kumarprateek1279 5 жыл бұрын
Really good implementation and loved your thought process.
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
thx
@zummotv1013
@zummotv1013 5 жыл бұрын
DataStructure and Algo group on WhatsApp.Please Join chat.whatsapp.com/GKVxU5dvU1e3v7h9ctDpXn
@kishantiwari3221
@kishantiwari3221 4 жыл бұрын
Great Explanation...Thankl you
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure
@asishsandhya
@asishsandhya 5 жыл бұрын
Great video dude..You made the problem so simpler. Thanks for that. I just subscribed to your channel.. yayyy
@BackToBackSWE
@BackToBackSWE 5 жыл бұрын
sure, welcome to the party
@Nampjg
@Nampjg 4 жыл бұрын
Loved your energy man!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
thanks
@quentinlassalle1321
@quentinlassalle1321 4 жыл бұрын
Awesome explanation, many thanks!
@BackToBackSWE
@BackToBackSWE 4 жыл бұрын
sure.
@sihanyang8393
@sihanyang8393 3 жыл бұрын
Where is the code plz? I didn't find it in the description. Thanks for the excellent video!
@lakshitaagarwal400
@lakshitaagarwal400 3 жыл бұрын
Awesome Explanation......... Can you please provide the code also as you said in the video.....I didnt find the code in description.
LeetCode 146. LRU Cache (Algorithm Explained)
18:00
Nick White
Рет қаралды 119 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,9 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 4,5 МЛН
LRU Cache - Twitch Interview Question - Leetcode 146
17:49
NeetCode
Рет қаралды 298 М.
How to Implement an LRU Cache (Leetcode #146 explained)
10:32
Byte by Byte
Рет қаралды 36 М.
Top 5 Redis Use Cases
6:28
ByteByteGo
Рет қаралды 188 М.