@sourabh :
*Cumulative SUM*
*i*
2
0
3
1
6
2
10
3
15
4
above will the array B[][] formed for array A[]={ 2,1,3,4,5 }
let X=12;
12 - 2 = 10 , closest element found = 10 , *closest to X = 2 + 10 =12*
,*i = 0 , j = 3
* // this is the answer , so i am calculating other
max number found closest to X=12 is 12
to return sub-array for this max sum
*i = 0 and j=3
*hence from given A[]={ 2,1,3,4,5 } we will get sub-array = {2,1,3,4} ( sum
= 2 + 1 + 3 + 4 = 10 )
sub-array should be from i = 2 to j = 4 which is {3,4,5} (sum = 3 + 4 + 5
= 12)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.