Code Room
CodingEasycod-g1303
Subject Prefix sumLevel Entry–Mid~12 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a list of integers and a window width w (w >= 1), return the sums of every contiguous window of exactly w elements, left to right. The result has length n - w + 1 for a list of length n; if w exceeds n, return an empty list. Values may be negative. Example: values = [1, 3, 2, 6], w = 2 gives [4, 5, 8].

Implement
window_totals(values: list[int], w: int) → list[int]
Examples
in[[1,3,2,6],2]out[4,5,8]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.