Sliding window: Given a positive-integer array nums and a positive target, return the minimum length of a contiguous subarray whose sum is at least target. Return 0 when no such subarray exists.
Input: A JSON object { "nums": number[], "target": number }.
Output: A JSON integer containing the minimum qualifying length, or 0.
Constraints:
- 0 <= nums.length <= 100000
- Every nums value is a positive integer
- target is a positive integer
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: MEDIUM. Variant: 2. Expect follow-up questions about complexity, edge cases, and alternative approaches.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked medium difficulty.
The signed-in workspace pr