Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecov-commenter commentedNov 17, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## master #949 +/- ##==========================================+ Coverage 95.39% 95.44% +0.05%========================================== Files 332 333 +1 Lines 21496 21532 +36 ==========================================+ Hits 20506 20552 +46+ Misses 990 980 -10 ☔ 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. |
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.