Given an array a[] = {1, 1 ,1 , -1} . you have to find all the subarrays of the given array whose sum is exactly = k.
example : a[] = { 1 , 1 , 1 , -1 }
Ans = 4 all 3 one's + range from [2,4]
There is an geeks_article for it but the explanation is not good and clear and also without proof .
Can anyone explain me how to solve this problem with some explanation !
Thanks !