Skip to content

Commit dbcbcb5

Browse files
chore(algorithms, sliding-window, max sum-subarray): account for all negative values
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 23a91a1 commit dbcbcb5

File tree

1 file changed

+1
-1
lines changed
  • algorithms/sliding_window/max_sum_of_subarray

1 file changed

+1
-1
lines changed

algorithms/sliding_window/max_sum_of_subarray/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def max_sum_subarray(nums: List[int], k: int) -> int:
1010

1111
start = 0
1212
state = 0
13-
max_sum = 0
13+
max_sum = float('-inf')
1414

1515
for end in range(n):
1616
state += nums[end]

0 commit comments

Comments
 (0)