You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Approach :- we traverse the array ans take two pointer both is initialised to (start = 0 & end = 0) in beginning as we move ahead we do ( tot + = nums[i] and end =i )
if the value is ( tot > target && (tot - nums[start] >target)) we do ( tot - = nums[start] ,start++) till the time ( start < end ) and our condition is satisfied
at the end if our ( tot>= target) we store the min value of ( (end -start)+1) in ans
*/
class Solution {
public:
int minSubArrayLen(int target, vector<int>& nums) {