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