-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/lru-cache
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Explanation:
LRUCache lRUCache = new LRUCache(2);
lRUCache.put(1, 10); // cache: {1=10}
lRUCache.get(1); // return 10
lRUCache.put(2, 20); // cache: {1=10, 2=20}
lRUCache.put(3, 30); // cache: {2=20, 3=30}, key=1 was evicted <--- key=2 should have be evicted as it was LRU and not key=1
lRUCache.get(2); // returns 20
lRUCache.get(1); // return -1 (not found)
Metadata
Metadata
Assignees
Labels
No labels