I Think We can Use HashTable , as Its Sub-Array you are asking about , its 
obviously contiguous :D
Calculate prefix sum  , store it in hashtable as key & current index as 
value , once prefix sum=k, print subarray , also keep track of prev index , 
so that we can print array from prev_i9ndex to current _index where sum=k

Time Complexity O(N)
Space Complexity O(N)

Correct me if anything wrong ?

Shashank Mani
Computer Science
Birla Institute of Technology,Mesra


-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/xCl1rX3yv5IJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to