LogiQuest
Back to Arrays
17

What is the output of the following code?

a = [2, -1, 3, -4, 5]
best = cur = a[0]
for x in a[1:]:
    cur = max(x, cur + x)
    best = max(best, cur)
print(best)
Hard

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.