У нас вы можете посмотреть бесплатно LRU Cache - LeetCode 146 | HashMap + Doubly Linked List in JavaScript | Day 34 или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
🎯 Day 34 of My LeetCode Journey | LRU Cache (LeetCode 146) In this video, I solve LeetCode Problem #146 - LRU Cache in JavaScript using HashMap + Doubly Linked List! This is a CLASSIC system design interview question that tests your understanding of data structures and O(1) operations. Perfect for FAANG interviews! 🔗 Problem Link: https://leetcode.com/problems/lru-cache/ 📌 PROBLEM DESCRIPTION: Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: • LRUCache(int capacity) Initialize the LRU cache with positive size capacity. • int get(key) Return the value of the key if it exists, otherwise return -1. • void put(key, value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity, evict the least recently used key. The functions get and put must each run in O(1) average time complexity. Example 1: Input: ["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] Output: [null, null, null, 1, null, -1, null, -1, 3, 4] Explanation: LRUCache lRUCache = new LRUCache(2); lRUCache.put(1, 1); // cache is {1=1} lRUCache.put(2, 2); // cache is {1=1, 2=2} lRUCache.get(1); // return 1 lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} lRUCache.get(2); // returns -1 (not found) lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} lRUCache.get(1); // return -1 (not found) lRUCache.get(3); // return 3 lRUCache.get(4); // return 4 💡 KEY CONCEPTS COVERED: ✅ LRU Cache Design Pattern ✅ HashMap for O(1) Lookup ✅ Doubly Linked List for O(1) Reordering ✅ Left/Right Dummy Nodes 📊 COMPLEXITY: • Time Complexity: O(1) for both get and put ⭐ • Space Complexity: O(capacity) 🎓 DIFFICULTY: Medium (but challenging!) 🏷️ TOPICS: Hash Table, Linked List, Design 🔔 SUBSCRIBE for daily LeetCode solutions in JavaScript! 👍 LIKE if you love design problems! 💬 COMMENT which company asked you this in interviews! --- 📚 MY LEETCODE JOURNEY PLAYLIST: • Leetcode 🤝 CONNECT WITH ME: • GitHub: https://github.com/ashwinikemshetty • LinkedIn: / ashwinikemshetty --- #LeetCode #LRUCache #LeetCode146 #Day34 #JavaScript #SystemDesign #HashMap #DoublyLinkedList #CodingInterview #FAANG #TechInterview #SoftwareEngineering #AlgorithmExplained #100DaysOfCode #JavaScriptTutorial #MediumProblem #DesignInterview