Minimum Size Subarray Sum

0Medium

Minimum Size Subarray Sum

Given an array of positive integers nums and positive integer target, return the minimal length of a subarray whose sum >= target. Return 0 if no such subarray.

Example 1:

Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 (subarray [4,3])

Example 2:

Input: target = 4, nums = [1,4,4] Output: 1

Example 3:

Input: target = 11, nums = [1,1,1,1,1,1,1,1] Output: 0

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕