The problem in this solution might be the fact that you will get the sub
array only if the prefix sum is k... so here we are not using prev index.


On Fri, Sep 2, 2011 at 3:17 PM, WgpShashank <shashank7andr...@gmail.com>wrote:

> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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