Question DSA-ARR-0062
HardWhat is the output of this code?
a = [1, 3, 5, 2, 4, 6]
res = []
best = float("-inf")
for x in a:
best = max(best, x)
res.append(best)
print(res)
- A.
[6, 6, 6, 6, 6, 6]
- B.
[1, 3, 5, 2, 4, 6]
- C.
Sign up free to see the answer and a step-by-step explanation.