You are given an array of integers nums and a positive integer k.
Your task is to find the maximum sum of any contiguous subarray of size exactly k.
Note that:
nums = [2, 1, 5, 1, 3, 2]
k = 3
9
The subarray [5, 1, 3] has the maximum sum of 9.
nums = [2, 3, 4, 1, 5]
k = 2
7
The subarray [2, 3] or [3, 4] both have a sum of 7, but there's no subarray of size 2 with a larger sum.
nums = [-1, -2, -3, -4]
k = 2
-3
The subarray [-1, -2] has the maximum sum of -3.
nums = [2, 1, 5, 1, 3, 2]
k = 3
9