Question PSC-ARR-0054
MediumWhat is the output of this pseudocode?
Integer a[5] = {3, -2, 5, -1, 4}
Integer best = a[0], cur = a[0], i
for (each i from 1 to 4)
cur = max(a[i], cur + a[i])
best = max(best, cur)
end for
Print best
- A.
9
- B.
8
- C.
Sign up free to see the answer and a step-by-step explanation.