Question bank › Sliding Window
Dsa Sliding Window Easy

Minimum Subarray Size for Sum

Given an array of positive integers and a positive integer S, find the minimal length of a contiguous subarray of which the sum is at least S. If there isn't one, return 0 instead. You must read the input as a single line where the first integer is the length of the array followed by the elements of the array and finally S. Example: Input: 5 2 3 1 2 4 7 Output: 2

Key concepts

sliding_windowsummin

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.