[Fix #108] Added Optimized Solutions for Range Sum Query and Subarray Sum Count #207
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.
Issue: #108
Summary
Added two well-structured and well-documented C++ solutions that demonstrate core Prefix Sum techniques under
algos/range_queries/prefixSum/soln/.Solution1.cpp
Implements efficient range sum queries using prefix sums, achieving
O(N) preprocessing time and O(1) time per query.
Solution2.cpp
Solves the problem of counting subarrays with a given sum using a combination of
prefix sums and hashing, with an overall O(N) time complexity.
Both solutions include:
All files compile successfully and are organized for readability, learning, and reuse.
Proof of Correctness (Codeforces Submissions)
Problem: Codeforces 1605B — Reverse Sort
Submission Link: https://codeforces.com/contest/1605/submission/356073603
Problem: Codeforces 1843E — Tracking Segments
Submission Link: https://codeforces.com/contest/1843/submission/356073814