Тёмный

LRU cache | Live Coding with Explanation | Leetcode  

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

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

 

15 сен 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!!
@milenitrivedi7561
@milenitrivedi7561 2 года назад
Great explanation !
@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; }
@dambar67
@dambar67 Год назад
map.remove(node), how it will remove ,here key should be given not the value.
@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)); } };
@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.
Далее
LRU Cache - Twitch Interview Question - Leetcode 146
17:49
What is LRU cache?
8:45
Просмотров 7 тыс.
Merab vs Sean underway!! 🚨 #ufc306
00:23
Просмотров 943 тыс.
Pure Comedy #ti13
00:38
Просмотров 229 тыс.
LeetCode 146. LRU Cache (Algorithm Explained)
18:00
Просмотров 117 тыс.
Candy | Live Coding with Explanation | Leetcode -135
18:09
LRU Cache -  Explanation, Java Implementation and Demo
23:41
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
The Flaws of Inheritance
10:01
Просмотров 940 тыс.