Question DSA-ARR-0008
MediumWhat is the output of this code?
a = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
best = cur = a[0]
for x in a[1:]:
cur = max(x, cur + x)
best = max(best, cur)
print(best)
- A.
5
- B.
6
- C.
Sign up free to see the answer and a step-by-step explanation.