Smallest subarray with required sum

Given an array of integers and a number x, find the smallest subarray(minimum number of elements) with sum greater than the given value x.

Note: There will be atleast one such subarray. In case of multiple possible subarrays of same size, return the first one.

Input format :

Line 1 : Size of input array

Line 2 : Array elements (separated by space)

Line 3 : x

Sample Input
6
1 3 5 6 4 3
9
Sample Output
 5 6

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem