max_sum as the sum of the first k elements.window_sum with the same value as max_sum.k to the end of the array.
a. Update window_sum by subtracting the element that is left out of the window (nums[i - k]) and adding the new element that enters the window (nums[i]).
b. Update max_sum with the maximum of max_sum and the new window_sum.max_sum / k as the maximum average.