Fixed-size sliding window: max sum of k consecutive numbers

Slide a window of k cells across the array. Instead of re-summing each window from scratch, update the running sum in O(1): add the value entering on the right, subtract the value leaving on the left. Track the largest sum seen.

window sum0 best so far0
current window entering value leaving value best window