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