- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
The Road To Google From Scratch — LRU Cache Optimized Solution
In this video we implement the optimized solution for the LRU Cache problem using a HashMap combined with a doubly linked list. Instead of scanning the cache to find the least recently used entry, we maintain O(1) time complexity for both get and put operations by using the HashMap for instant lookup and the doubly linked list for instant reordering.
We break down the solution step by step:
1.Understand the problem requirements — design a data structure with O(1) get and put that evicts the least recently used key when capacity is exceeded
2.Design the data structure: HashMap from key to Node, plus a doubly linked list with dummy head and tail to track usage order
3.Implement the get operation — look up the node in the map, move it to the front of the list, return its value
4.Implement the put operation — if the key exists update and move to front, if at capacity evict the tail node, then insert the new node at the front
5.Implement the helper remove and insert operations — relink prev and next pointers in O(1)
6.Handle edge cases — missing key, capacity overflow, updating existing key
Timeline:
0:00 - Condition
0:42 - Visualization
5:22 - Solution
#leetcode #lrucache #design #hashmap #doublylinkedlist #codinginterview #java #python #algorithms #datastructures #medium #faang #interviewprep #cache
Видео The Road To Google From Scratch — LRU Cache Optimized Solution канала Alex_Pro
We break down the solution step by step:
1.Understand the problem requirements — design a data structure with O(1) get and put that evicts the least recently used key when capacity is exceeded
2.Design the data structure: HashMap from key to Node, plus a doubly linked list with dummy head and tail to track usage order
3.Implement the get operation — look up the node in the map, move it to the front of the list, return its value
4.Implement the put operation — if the key exists update and move to front, if at capacity evict the tail node, then insert the new node at the front
5.Implement the helper remove and insert operations — relink prev and next pointers in O(1)
6.Handle edge cases — missing key, capacity overflow, updating existing key
Timeline:
0:00 - Condition
0:42 - Visualization
5:22 - Solution
#leetcode #lrucache #design #hashmap #doublylinkedlist #codinginterview #java #python #algorithms #datastructures #medium #faang #interviewprep #cache
Видео The Road To Google From Scratch — LRU Cache Optimized Solution канала Alex_Pro
Комментарии отсутствуют
Информация о видео
3 мая 2026 г. 19:24:29
00:20:29
Другие видео канала





















