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