Тёмный

LRU cache | Live Coding with Explanation | Leetcode  

Algorithms Made Easy
Подписаться 38 тыс.
Просмотров 7 тыс.
50% 1

What is LRU Cache?: • What is LRU cache?
Get Discount on GeeksforGeeks courses (practice.geeks...) by using coupon code: ALGOMAEASY
To support us you can donate
Patreon: / algorithmsmadeeasy
UPI: algorithmsmadeeasy@icici
Paypal: paypal.me/algorithmsmadeeasy
Check out our other popular playlists:
✅✅✅[ Tree Data Structure ] : • Tree Data Structure
✅✅✅[ Graphs Data Structure ] : • Graph Data Structure
✅✅✅[ December Leetcoding Challenge ] : • December Leetcoding Ch...
✅✅✅[ November Leetcoding Challenge ] : • November Leetcoding Ch...
✅✅✅[ August Leetcoding Challenges ] : • August LeetCoding Chal...
✅✅✅[ July Leetcoding Challenges ] : • July LeetCoding Challe...
✅✅✅[ Cracking the Coding Interview - Unique String ] : • Cracking the Coding In...
✅✅✅[ June Leetcoding Challenges ] : • June LeetCoding Challe...
✅✅✅[ May Leetcoding challenges ]: • May LeetCoding Challen...
Problem Link: leetcode.com/p...
Code: github.com/Alg...
If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.
#coding #leetcode #programminglife #programmingisfun #programmer #tech #software #codinglife #leetcode

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

 

6 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 14   
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 3 года назад
We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!! Questions you might like: ✅✅✅[ Tree Data Structure ] : ru-vid.com/group/PLJtzaiEpVo2zx-rCqLMmcFEpZw1UpGWls ✅✅✅[ Graphs Data Structure ] : ru-vid.com/group/PLJtzaiEpVo2xg89cZzZCHqX03a1Vb6w7C ✅✅✅[ January Leetcoding Challenge ] : ru-vid.com/group/PLJtzaiEpVo2wCalBcRcNjXQ0C6ku3dRkn ✅✅✅[ December Leetcoding Challenge ] : ru-vid.com/group/PLJtzaiEpVo2xo8OdPZxrpybGR8FmzZpCA ✅✅✅[ November Leetcoding Challenge ] : ru-vid.com/group/PLJtzaiEpVo2yMYz5RPH6pfB0wNnwWsK7e ✅✅✅[ August Leetcoding Challenge ] : ru-vid.com/group/PLJtzaiEpVo2xu4h0gYQzvOMboclK_pZMe ✅✅✅July Leetcoding challenges: ru-vid.com/group/PLJtzaiEpVo2wrUwkvexbC-vbUqVIy7qC- ✅✅✅June Leetcoding challenges: ru-vid.com/group/PLJtzaiEpVo2xIfpptnCvUtKrUcod2zAKG ✅✅✅May Leetcoding challenges: ru-vid.com/group/PLJtzaiEpVo2wRmUCq96zsUwOVD6p66K9e ✅✅✅Cracking the Coding Interview - Unique String: ru-vid.com/group/PLJtzaiEpVo2xXf4LZb3y_BopOnLC1L4mE Struggling in a question?? Leave in a comment and we will make a video!!!🙂🙂🙂
@shivendra2076
@shivendra2076 2 года назад
Under rated channel, Thanks bro, understood it
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 2 года назад
Thank you!! Do not forget to subscribe to the channel!! 😊😊
@pranavananth6617
@pranavananth6617 6 месяцев назад
one of the best solution...
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 6 месяцев назад
Thank you!!
@appprocessorsappdevelopmen8405
@appprocessorsappdevelopmen8405 3 года назад
*insert() method without declaring headNext* void insert(Node node){ //insert into map map.put(node.key,node); //point node's next to head's next node.next = head.next; //point head's next' prev to node head.next.prev = node; head.next=node; node.prev=head; }
@milenitrivedi7561
@milenitrivedi7561 2 года назад
Great explanation !
@RupamSasmalYt
@RupamSasmalYt Год назад
Have done the same approach with c++, but it's giving TLE. Can't find any single solution in c++ without tle in leetcode :( C++ Code: class Node{ public: int key, val; Node *prev, *next; Node(int key,int val){ this->key=key; this->val=val; } }; class LRUCache { public: int cap; Node* head=new Node(0,0); Node* tail=new Node(0,0); unordered_map mp; LRUCache(int capacity) { cap=capacity; head->next=tail; tail->prev=head; } void Add(Node* newNode){ mp[newNode->key]=newNode; Node* tmp=head->next; head->next=newNode; newNode->prev=head; newNode->next=tmp; tmp->prev=newNode; } void Delete(Node* node){ mp.erase(node->key); node->prev->next=node->next; node->next->prev=node->prev; } int get(int key) { if(mp.find(key)!=mp.end()){ // key present Node* resNode=mp[key]; Delete(resNode); Add(resNode); return resNode->val; } return -1; } void put(int key, int value) { if(mp.find(key)!=mp.end()){ // key is present Delete(mp[key]); } if(mp.size()==cap){ Delete(tail->prev); } Add(new Node(key,value)); } };
@dambar67
@dambar67 Год назад
map.remove(node), how it will remove ,here key should be given not the value.
@CRamPrasannaCV
@CRamPrasannaCV 3 года назад
Understood :-)
@omarkhan5223
@omarkhan5223 2 года назад
@5:40 You remove tail.prev. I thought you would remove tail because the tail of linked list is the last node, isn't tail.prev the second last node?? Why is this not the case?
@054_heenaahmed8
@054_heenaahmed8 2 года назад
tail is the dummy node that is at end of linkedlist , similar to head , which is also dummy at start of linkedlist . we have used it to simplify the operations , and get access to last(using tail) and first(using head) node in O(1).
@rilkedev449
@rilkedev449 2 года назад
@@054_heenaahmed8 Thank you.
@sayyidiskandarkhan3064
@sayyidiskandarkhan3064 Год назад
it would have been great had he covered this in the explaination but i had to look at the comments to find the results.
Далее
What is LRU cache?
8:45
Просмотров 7 тыс.
LFU Cache - Leetcode 460 - Python
14:45
Просмотров 25 тыс.
LeetCode 146. LRU Cache (Algorithm Explained)
18:00
Просмотров 117 тыс.
Implement LRU cache
12:25
Просмотров 123 тыс.