Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add Basic Prefix Sum Algorithm with Tests (Fixes #1783)#1798

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

Open
Anshusinghh wants to merge1 commit intoTheAlgorithms:master
base:master
Choose a base branch
Loading
fromAnshusinghh:master

Conversation

Anshusinghh
Copy link

FIXES#1783

What does this PR do?

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

Details

  • ImplementsprefixSum inPrefix-Sum/BasicPrefixSum.js
    • Validates input (must be numeric array).
    • ThrowsTypeError on invalid inputs.
    • Modifies the array in-place and returns the same reference.
  • AddsPrefix-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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@raklaptudirmraklaptudirmAwaiting requested review from raklaptudirmraklaptudirm is a code owner

@appgurueuappgurueuAwaiting requested review from appgurueuappgurueu is a code owner

At least 2 approving reviews are required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add Basic Prefix Sum Algorithm with Tests
1 participant
@Anshusinghh

[8]ページ先頭

©2009-2025 Movatter.jp