@Priyanka ...Do the elements of the subarray need to be continuous ..The
example considers it continuous but still just for clarity ?

On Tue, Jan 10, 2012 at 12:50 AM, surender sanke <surend...@gmail.com>wrote:

> using extra space of O(n) we can do it in O(n^2)
> take an array for storing cumulative sums from index i till 0,
> then from i+1 till n-1 find summing each array value find whether it
> exists in array.
> if its so display indexes
> eg
> Array: 2,2,13,4,7,3,8,12,9,1,5
> i = 3               ^
> temp array:  4, 17, 19, 21
> finding for cumulative sums from i+1 till i<=(any of values in temp array)
> i = 6               ^
> temp array:  8, 11, 18, 22
> finding for cumulative sums from i+1 till i<=(any of values in temp array)
> found values from i+1 till i+3
> Repeating for every i,
>
> surender
>
>
> On Mon, Jan 9, 2012 at 11:22 PM, priyanka jaggi 
> <priyankajag...@gmail.com>wrote:
>
>> Given an array (length n), we need to find the subarray (length k) such
>> that the sum of the first j elements of the subarray equals the sum of the
>> remaining (k-j) elements of the subarray.
>> For e.g.
>> Array: 2,2,13,4,7,3,8,12,9,1,5
>> Output: 4,7,3,8,12,9,1 [4+7+3+8=12+9+1]
>> Could this be done with a complexity better than O(n^3)
>> k is not given .
>>
>> --
>> 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.
>>
>
>  --
> 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.
>

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