Approach hintTry it first, then revealHide
Removing elements from both ends leaves a contiguous subarray, so find the longest window whose sum is exactly s and answer n minus its length, or -1 when the total is below s.
Removing elements from both ends leaves a contiguous subarray, so find the longest window whose sum is exactly s and answer n minus its length, or -1 when the total is below s.