Search⌘ K
AI Features

Minimum Size Subarray Sum

Explore how to find the length of the smallest contiguous subarray in an array where the sum is at least a given target. This lesson teaches you to use a two-pointer approach to achieve an optimal linear time solution, deepening your understanding of array algorithms and subarray problems.

Statement

Given an array of positive integers, nums, along with a positive integer, target. Find the length of the shortest contiguous subarray whose sum is greater than or equal to the target. If there is no such subarray, return 0 instead.

Example

Sample input

 ...