Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Minimum Size Subarray Sum

XPChallenge Points: 20
levelLevel: Medium

You are given an array of positive integers nums and a positive integer target.
Your task is to find the smallest length of a contiguous subarray whose sum is greater than or equal to target.

If no such subarray exists, return 0.

Example 1:

Input: target = 15, nums = [5,1,3,5,10,7,4,9,2,8]

Output: 2

Example 2:

Input: target = 9, nums = [2,3,1,2,4,3]

Output: 2

Example 3:

Input: target = 20, nums = [1,2,3,4,5]

Output: 0

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result