Question DSA-ARR-0063
HardWhat is the output of this code?
a = [2, 3, -2, 4, -1]
mx = mn = best = a[0]
for x in a[1:]:
if x < 0:
mx, mn = mn, mx
mx = max(x, mx * x)
mn = min(x, mn * x)
best = max(best, mx)
print(best)
- A.
4
- B.
6
- C.
Sign up free to see the answer and a step-by-step explanation.