Skip to content

Commit f9ac741

Browse files
committed
complexity analysis
1 parent 04f4933 commit f9ac741

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sprint-2/implement_lru_cache/lru_cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@ def set(self, key, value): #Insert/update value and handle eviction
6767
# Remove least recently used node
6868
tail = self.dll.pop_tail()
6969
del self.cache[tail.key]
70+
#Time Complexity = O(1) since each operations have the same O(1) complexity
71+
#Total Space complexity is O(n) i.e. One node and one dictionary entry per cached item

0 commit comments

Comments
 (0)