Dsa
Sliding Window
Easy
Minimum Size Subarray Sum
Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead.
Input:
- The first line contains an integer n (1 ≤ n ≤ 10^5): the size of the array.
- The second line contains n positive integers.
- The third line contains the target integer.
Output:
- An integer representing the minimal length of the subarray with sum >= target.
Example:
Input:
8
2 3 1 2 4 3
7
Output:
2
Key concepts
sliding_windowarraysummation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now