9.Minimum Size Subarray Sum >=k (positive no)
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.
Algo:
This technique is similar toSliding Window Technique.
Create variables, start=0, sum = 0
Traverse the array from start to end.
Update the variable sum by adding current element, sum = sum + array[i]
If the sum is greater than the given sum, update the variable sum as sum = sum – array[start], and update start.
Solution : (Sliding Window)
Last updated