You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Implement LRU Cache - #244
I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
My changes meet the requirements of the task
I have tested my changes
My changes follow the style guide
Task code
CYF-1181
Changelist
Implemented an O(1) worst-case time complexity LRU Cache using a Python dictionary for instant lookups and a Doubly Linked List for tracking usage order.
Added strict limit validation in the constructor to raise a ValueError for zero or negative limits.
Handled edge cases including single-node lists, middle-node re-linking, and tail eviction.
Verified implementation against the provided test suite (lru_cache_test.py) with all tests passing successfully.
The reason will be displayed to describe this comment to others. Learn more.
To better adhere to the Single-Responsibility Principle (SRP) from SOLID design principles, it's preferable to implement the "doubly linked list" and the "LRU Cache" as separate classes, with the linked list used inside LruCache to manage ordering.
You could copy your linked_list.py to this folder.
Alternatively, use a suitable Python built-in class to maintain order.
Could you update your code using one of these approaches?
cjyuan
added
Reviewed
Volunteer to add when completing a review with trainee action still to take.
and removed
Needs Review
Trainee to add when requesting review. PRs without this label will not be reviewed.
labels
Oct 13, 2026
Hi @cjyuan ,
Great catch and thanks for pointing out the SOLID principles! I've refactored the code to completely separate the DoublyLinkedList and LruCache into distinct classes. Now, LruCache handles only cache operations and delegates all node ordering/pointer manipulation to the DoublyLinkedList to properly adhere to the Single-Responsibility Principle.
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
cjyuan
added
Complete
Volunteer to add when work is complete and all review comments have been addressed.
and removed
Needs Review
Trainee to add when requesting review. PRs without this label will not be reviewed.
Reviewed
Volunteer to add when completing a review with trainee action still to take.
labels
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CompleteVolunteer to add when work is complete and all review comments have been addressed.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Task code
CYF-1181
Changelist
limitvalidation in the constructor to raise aValueErrorfor zero or negative limits.lru_cache_test.py) with all tests passing successfully.Questions
No questions—all unit tests passed successfully!