Implement a Least Recently Used cache with O(1) get and put operations. Use a combination of HashMap and doubly-linked list.
class LRUCache {
constructor(capacity) {
this.capacity = capacity;
this.cache = new Map();
}
// ...Implement a Least Recently Used cache with O(1) get and put operations. Use a combination of HashMap and doubly-linked list.
class LRUCache {
constructor(capacity) {
this.capacity = capacity;
this.cache = new Map();
}
// ...