Skip to content

Conversation

@Anshusinghh
Copy link

@Anshusinghh Anshusinghh commented Sep 24, 2025

What does this PR do?

This PR adds an implementation of the Prefix Sum algorithm (in-place cumulative sum) in JavaScript.

Details

  • Implements prefixSum in Prefix-Sum/BasicPrefixSum.js
    • Validates input (must be numeric array).
    • Throws TypeError on invalid inputs.
    • Modifies the array in-place and returns the same reference.
  • Adds Prefix-Sum/BasicPrefixSum.test.js with unit tests using Vitest.
    • Covers integers, negatives, floats, empty input, and error handling.

Why is this needed?

Prefix sum is a fundamental algorithm widely used in competitive programming and data processing. Having an in-place implementation ensures O(1) extra space.

Checklist

  • Code follows repository style guidelines
  • Added tests with Vitest
  • npm test passes locally
  • No console statements

Thanks for reviewing 🙏 Please let me know if changes are needed.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.93%. Comparing base (08d8c6b) to head (0b727bf).

Additional details and impacted files
@@ Coverage Diff @@ ## master #1797 +/- ## ========================================== + Coverage 85.91% 85.93% +0.01%  ========================================== Files 379 380 +1 Lines 19778 19800 +22 Branches 3015 3023 +8 ========================================== + Hits 16993 17015 +22  Misses 2785 2785 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@Anshusinghh Anshusinghh changed the title feat: Add Basic Prefix Sum Algorithm with Tests feat: Add Basic Prefix Sum Algorithm with Tests. FIXES #1783 Sep 24, 2025
@Anshusinghh Anshusinghh deleted the feat/prefixSum branch September 24, 2025 07:18
@Anshusinghh Anshusinghh restored the feat/prefixSum branch September 24, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants