Question DSA-TP-0008
MediumWhat is the output of this code?
a, k = [2, 1, 5, 1, 3, 2], 3
s = sum(a[:k])
best = s
for i in range(k, len(a)):
s += a[i] - a[i - k]
best = max(best, s)
print(best)
- A.
7
- B.
12
- C.
Sign up free to see the answer and a step-by-step explanation.