Number of subarrays with sum exactly = k.

Revision en2, by a_journey, 2019-02-05 15:17:44

Given an array a[] = {1, 1 ,1 , -1} . you have to find all the subarrays of the given array whose sum is exactly = k.

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 !

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English a_journey 2019-02-05 15:22:55 11 Tiny change: ' 1 , -1 } \n\nAns =' -> ' 1 , -1 } and k = 1 \n\nAns ='
en4 English a_journey 2019-02-05 15:20:39 81
en3 English a_journey 2019-02-05 15:18:17 6
en2 English a_journey 2019-02-05 15:17:44 4 Tiny change: 'xactly =_ ****k.\n\n\nTh' -> 'xactly =_ k.\n\n\nTh'
en1 English a_journey 2019-02-05 15:17:25 430 Initial revision (published)