Yet Another Off By One Error
This commit is contained in:
parent
3580198513
commit
01a189c5ee
@ -544,7 +544,7 @@ def sum_max_sub_array(nums: list[int]) -> int:
|
|||||||
max_sum: int = sum(nums)
|
max_sum: int = sum(nums)
|
||||||
|
|
||||||
while end - begin <= len(nums):
|
while end - begin <= len(nums):
|
||||||
while end < len(nums):
|
while end <= len(nums):
|
||||||
max_sum = max(max_sum, sum(nums[begin:end]))
|
max_sum = max(max_sum, sum(nums[begin:end]))
|
||||||
begin += 1
|
begin += 1
|
||||||
end += 1
|
end += 1
|
||||||
|
@ -461,6 +461,10 @@ def test_trie_busy():
|
|||||||
[5, 4, -1, 7, 8],
|
[5, 4, -1, 7, 8],
|
||||||
23,
|
23,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
[-2, 1],
|
||||||
|
1,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_maximum_subarray(nums: list[int], expected: int):
|
def test_maximum_subarray(nums: list[int], expected: int):
|
||||||
|
Loading…
Reference in New Issue
Block a user