Apple | Consecutive integers in a unsorted array add to sum k

1780
Mar 02, 2019
Nov 05, 2019

Given an array of integers of size N, find consecutive integers(sub array) which would sum up to S. If there are more than 1 sub-array which would sum up to S, list them all.

Sample input
[1,4,8,2,1,3,1]

S = 3
Expected Output
2,1
3

S = 4
Expected Output
4
1,3
3,1

expected O(n) solution

Comments (4)