clean of unnecessary checks, imports, calls (#7993)

This commit is contained in:
Mark Mayo
2022-11-21 00:00:27 +13:00
committed by GitHub
parent a25c53e8b0
commit f32d611689
27 changed files with 44 additions and 57 deletions

View File

@ -11,10 +11,8 @@ def max_sub_array_sum(a: list, size: int = 0):
max_ending_here = 0
for i in range(0, size):
max_ending_here = max_ending_here + a[i]
if max_so_far < max_ending_here:
max_so_far = max_ending_here
if max_ending_here < 0:
max_ending_here = 0
max_so_far = max(max_so_far, max_ending_here)
max_ending_here = max(max_ending_here, 0)
return max_so_far