Cobblestone Energy interview question

Standard sliding window problem from leetcode