Question DSA-ARR-0046
MediumWhat is the output of this code?
a = [1, 2, 3, 4]
n = len(a)
out = [1] * n
left = 1
for i in range(n):
out[i] = left
left *= a[i]
right = 1
for i in range(n - 1, -1, -1):
out[i] *= right
right *= a[i]
print(out)
- A.
[1, 2, 6, 24]
- B.
[24, 6, 2, 1]
- C.
Sign up free to see the answer and a step-by-step explanation.