Shortest Window Reaching the Target

L4 Easy Sliding Window
Concept
When every element is non-negative, a window whose sum is at least the target can shrink from the left and still stay valid — the classic "shrink-when-satisfied" sliding window.
Given an array nums of positive integers and a positive target, return the length of the shortest contiguous subarray whose sum is at least target. If no such subarray exists, return 0.
Examples
▸ target = 7, nums = [2, 3, 1, 2, 4, 3]
→ 2
▸ target = 4, nums = [1, 4, 4]
→ 1
▸ target = 11, nums = [1, 1, 1, 1, 1, 1, 1, 1]
→ 0
Progressive Hints
Hint 1 · Nudge
Once a window qualifies, save it, then try to make it shorter.
Hint 2 · Plan
Keep a window with a running sum and a left pointer. Extend the right side adding elements. Once the sum reaches target, save the window length, then shrink from the left while the sum still qualifies, updating the best length. Return the shortest length found, or 0.
Hint 3 · Approach
left = 0, s = 0, best = a very large value. For each right, n: s = s + n. While s >= target: best = the smaller of best and right - left + 1, then s = s - nums[left] and left = left + 1. Return best if it was ever updated, else 0.
Output
// Run your code to see the output here.