Problem intuition
The brute-force version recalculates each window sum from scratch.
The sliding-window version keeps the current sum and updates it by removing the outgoing number and adding the incoming one.
Java solution ladder
The solutions below are ordered from least optimal to most optimal, so you can see the improvement path instead of only the final answer.