1.2 Smallest Subarray with a given sum (easy)
Problem Statement
Input: [2, 1, 5, 2, 3, 2], S=7
Output: 2
Explanation: The smallest subarray with a sum greater than
or equal to '7' is [5, 2].Input: [2, 1, 5, 2, 8], S=7
Output: 1
Explanation: The smallest subarray with a sum greater than
or equal to '7' is [8].Input: [3, 4, 1, 1, 6], S=8
Output: 3
Explanation: Smallest subarrays with a sum greater than
or equal to '8' are [3, 4, 1] or [1, 1, 6].Solution
Time Complexity
Space Complexity
Previous1.1 Maximum Sum Subarray of Size K (easy)Next1.3 Longest Substring with K Distinct Characters (medium)
Last updated