Given an array of n integers, and a moving window(size k), move the window at each iteration from the start of the array, find the sum of the element inside the window at each moving.
Example
Input:array = [1,2,7,8,5], k = 3
Output:[10,17,20]
Explanation:
1 + 2 + 7 = 10
2 + 7 + 8 = 17
7 + 8 + 5 = 20
Code
1 | public int[] winSum(int[] nums, int k) { |