itsakshayv / Hacktoberfest2020-contribution

This repository is for Hacktober fest 2020.you can create any program in Any Language.
2 stars 44 forks source link

Smallest Subarray with a given sum #53

Closed PinkyWalia closed 3 years ago

PinkyWalia commented 3 years ago

Given an array of positive numbers and a positive number ‘S’, find the length of the smallest contiguous subarray whose sum is greater than or equal to ‘S’. Return 0, if no such subarray exists.

Input: [2, 1, 5, 2, 3, 2], S=7 Output: 2