-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add subarray sum equals k algorithm #949
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
feat: add subarray sum equals k algorithm #949
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #949 +/- ##
==========================================
+ Coverage 95.39% 95.93% +0.54%
==========================================
Files 332 362 +30
Lines 21496 24649 +3153
==========================================
+ Hits 20506 23647 +3141
- Misses 990 1002 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@MNnazrul I like this algorithm because it's simple and intuitive. imp2002 seems to be inactive, you can ask another reviewer for your PR. |
d900c41 to
5ef7b3d
Compare
|
@zhangzhuang15 I'm unable to change the reviewer from my side.
|
|
I've received your message, and will respond as soon as possible.
|
|
Could you please take a look at this PR if you have spare time? @siriak From my perspective, this PR is simple and friendly for beginning learners.
By the way, imp2002 is not active for review these days, he/she may be really busy. Is there someone else taking own of this code repo and helping imp2002 review PR ? @siriak |
siriak
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.
Looks good, but don't add more Leetcode problems, we usually don't add them. I think there are no other reviewers now unfortunately.
All right., what a pity. Thanks for your response. |


Description
This PR adds an implementation of the "Subarray Sum Equals K" algorithm to the
generalmodule. The algorithm counts the number of contiguous subarrays that sum to exactlyk.Implementation Method:
Algorithm Reference:
This is a classic LeetCode problem (Problem 560). The solution uses the prefix sum approach where we track cumulative sums and check if
prefix_sum - kexists in our map, which indicates a subarray with sumkexists.Type of change
Checklist:
cargo clippy --all -- -D warningsjust before my last commit and fixed any issue that was found.cargo fmtjust before my last commit.cargo testjust before my last commit and all tests passed.mod.rsfile within its own folder, and in any parent folder(s).DIRECTORY.mdwith the correct link.CONTRIBUTING.mdand my code follows its guidelines.