2 Commits

Author SHA1 Message Date
Pranjay kumar
580273eeca
Improve prefix_sum.py (#12560)
* Update prefix_sum.py

Index Validation for get_sum

Raises ValueError if start or end is out of range or start > end.
Handles cases where the array is empty.
 Empty Array Support

If an empty array is passed, get_sum raises an appropriate error instead of failing unexpectedly.
 Optimized contains_sum Initialization

Initializes sums with {0} for efficient subarray sum checking.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update prefix_sum.py

* Update prefix_sum.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update prefix_sum.py

* Update prefix_sum.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-03-20 02:33:46 +03:00
Alexander Pantyukhin
7f1a5521f4
add prefix sum (#7959)
* add prefix sum

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-04 20:30:32 +13:00