Question DSA-TP-0011
MediumWhat is the output of this code?
a, target = [2, 3, 1, 2, 4, 3], 7
l = s = 0
best = float('inf')
for r, x in enumerate(a):
s += x
while s >= target:
best = min(best, r - l + 1)
s -= a[l]
l += 1
print(best)
- A.
1
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.