-
Notifications
You must be signed in to change notification settings - Fork 2
feat(algorithms, greedy): minimum number of pushes to type word #165
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
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds a new Greedy algorithm "Minimum Number of Pushes to Type Word" with two implementations (sorting-based and heap-based), tests, README, and a DIRECTORY.md update that also adds an entry for Longest Increasing Subsequence under Dynamic Programming and removes a duplicate LIS entry under Puzzles > Arrays. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@algorithms/greedy/minimum_number_of_pushes/__init__.py`:
- Around line 5-14: In the function minimum_pushes_greedy_with_sorting, fix the
typos in the comments: change "storees" to "stores" in the comment describing
the frequency vector and change "throuch" to "through" in the loop comment; no
code logic changes needed—just update the comment text around the frequency =
[0] * 26 line and the for char in word: loop comment to correct the spelling.
In `@algorithms/greedy/minimum_number_of_pushes/README.md`:
- Around line 112-116: Fix the minor markdown formatting on the README by
replacing the double space after the blockquote marker on the affected line
(change "> " to "> ") so the quoted paragraph renders consistently; locate the
quoted paragraph starting with "the number of pushes required to obtain a single
instance..." in algorithms/greedy/minimum_number_of_pushes/README.md and
normalize the blockquote punctuation.
🧹 Nitpick comments (1)
algorithms/greedy/minimum_number_of_pushes/__init__.py (1)
16-19: Clarify complexity comment for sorting.The comment says "O(n log(n)) operation" and "space complexity of O(n)", but the array being sorted is always size 26 (constant), not
n. This is effectively O(1) time and O(1) auxiliary space. Consider updating the comment for accuracy:📝 Suggested clarification
- # Sort the frequencies in descending order to prioritize letters with higher counts - # O(n log(n)) operation to handle sorting, with a space complexity of O(n) as Python uses in-memory space to handle - # the sorting using timsort + # Sort the frequencies in descending order to prioritize letters with higher counts + # O(26 log 26) = O(1) operation since the array size is constant (26 letters) frequency.sort(reverse=True)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Describe your change:
Minimum number of pushes to type word on a phone keypad using greedy algorithm and an alternative using a max heap
Checklist:
Fixes: #{$ISSUE_NO}.Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.