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