intermediate

This commit is contained in:
Fabian Freund
2024-12-12 09:44:33 +01:00
parent 0710116feb
commit 6b2ae28828
108 changed files with 5531 additions and 2265 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ class LRUCache<K, V> {
return value;
}
void set(K key, V value) {
V set(K key, V value) {
if (_cache.containsKey(key)) {
_cache.remove(key); // Remove the existing item before updating.
} else if (_cache.length == _capacity) {
@@ -43,6 +43,6 @@ class LRUCache<K, V> {
); // Explicitly remove the least recently used item if at capacity.
}
_cache[key] = value; // Inserting or updating the item.
return _cache[key] = value; // Inserting or updating the item.
}
}