-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Solution #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Solution #1110
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Great job on implementing the core functionality of the Dictionary class! The overall structure is solid. However, a couple of changes are needed to fully meet the project requirements.
First, the task description specifies that each node should store the key, hash, and value. Your current implementation in app/main.py only stores the key and value. Please update your node structure to include the pre-calculated hash.
Additionally, the KeyError you raise in __getitem__ is missing a descriptive message, which is a checklist requirement. It's important to provide context for the error, for example: raise KeyError(f"Key not found: {key}").
Once these two points are addressed, your solution will be fully compliant. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Great job addressing the previous feedback! Your Dictionary class is well-implemented and meets all the requirements, so I am approving your submission. The logic for handling nodes, including storing the hash and providing descriptive error messages, is solid.
As a small suggestion for future improvement, in your _resize method, you recalculate the hash of the key to find its new index. Since you already have the hash stored in the node, you can make this more efficient by using the stored value directly. This is a minor optimization, and your current code works perfectly. Keep up the fantastic work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| for bucked in self.table: | ||
| for node in bucked: | ||
| key, hash_key, value = node | ||
| new_index = hash(key) % new_capacity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're recalculating the hash of the key here, but the hash_key is already available from the node you're processing. Consider using the stored hash to determine the new_index to make this more efficient and align with the purpose of storing the hash in the first place.
No description provided.