Skip to content

Commit

Permalink
fix initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
antrianis committed Feb 13, 2015
1 parent 8be9dd2 commit 8e8ff00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion misc/kadane.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def find_max_subarray(numbers):

def find_max_subarray2(numbers):
""" shorter version """
max_till_here = [numbers[0]]
max_till_here = [0]
for n in numbers:
max_till_here.append(max(n, max_till_here[-1] + n))
return max(max_till_here)
Expand Down

0 comments on commit 8e8ff00

Please sign in to comment.