Code Room
Code reviewMediumcr-g274
Subject Off by oneLevel Mid–Senior~16 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Review this Python sliding-window sum that produces the sum of every contiguous window of size k.

Called in a metrics pipeline; `k` is user-configurable.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def window_sums(a, k):    sums = []    s = sum(a[:k])    sums.append(s)    for i in range(k, len(a)):        s += a[i] - a[i - k]        sums.append(s)    return sums
Run or narrate your approach, then ask the coach.