Cracking the coding interview: Subarray with given sum — 6

Input:
N = 5, S = 12
A[] = {1,2,3,7,5}
Output: 2 4
Explanation:
The sum of elements
from 2nd position to 4th position
is 12.
Input:
N = 10, S = 15
A[] = {1,2,3,4,5,6,7,8,9,10}
Output: 1 5
Explanation:
The sum of elements
from 1st position to 5th position
is 15.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store