Question
Given an integer array nums and a window size k (1 <= k <= length of nums), return a list containing the sum of every window of k consecutive elements, from the leftmost window to the rightmost — n - k + 1 sums in total. Compute each subsequent sum from the previous one in O(1) rather than re-adding k elements. Example: nums = [1, 2, 3, 4], k = 2 gives [3, 5, 7].
window_sums(nums: list[int], k: int) → list[int][[1,2,3,4],2]out[3,5,7]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.