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