Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 25, 2025
1 parent 180b28f commit 175dc9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dynamic_programming/prefix_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def prefix_sum(array: list[int], queries: list[tuple[int, int]]) -> list[int]:
dp = [0] * len(array)
dp[0] = array[0]
for i in range(1, len(array)):
dp[i] = dp[i-1] + array[i]
dp[i] = dp[i - 1] + array[i]

# Read Algorithm section (Line 38)
result = []
for query in queries:
res = dp[query[1]]
if query[0] != 0:
res -= dp[query[0]-1]
res -= dp[query[0] - 1]
result.append(res)

return result
Expand Down

0 comments on commit 175dc9c

Please sign in to comment.