Skip to content

Commit d2cc78c

Browse files
Update datastructures/lfucache/README.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 0271ed9 commit d2cc78c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

datastructures/lfucache/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ After implementing `PromoteKey()`, the LFU cache functions are implemented as fo
6464
- `Put`: We check if the key exists in the cache.
6565
- If it doesn't, we must add this (key, value) pair to our cache.
6666
- Before adding it, we check if the cache has already reached capacity. If it has, we remove the LFU key. To do that,
67-
we remove the head node of the linked list accociated with the frequency equal to `minimum_frequency`.
68-
- If it does, we simply update key with the value.
69-
- At the end of both steps, we adjust the frequency order of the key using `PromoteKey()`.
67+
we remove the head node of the linked list associated with the frequency equal to `minimum_frequency`.
68+
- Then we add the new key.
69+
- If the key already exists, we simply update its value.
70+
- At the end of both cases, we adjust the frequency order of the key using `PromoteKey()`.
7071

7172
![Solution 1](./images/solutions/lfu_cache_solution_1.png)
7273
![Solution 2](./images/solutions/lfu_cache_solution_2.png)

0 commit comments

Comments
 (0)