It is simple. Here are the steps,
tot = sum of the entire array
max = tot
start = 0
end = n-1
sub_start = start
sub_end = end
while ( start < end )
{ if ( array[start] < array[end] )
{ tot=tot-array[start]
start++
}
else
{ tot=tot-array[start]
end--
}
if ( tot >= max
Yes, am sorry, its infact the continous sub-sequence which I missed
in the question.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegr
I think it it max sub-sequence problem which is discussed on this link : http://discuss.fogcreek.com/techinterview/default.asp?cmd=show&ixPost=3052
On 4/5/06, Vijendra Singh <[EMAIL PROTECTED]> wrote:
I dont get it, if its just the subset, then just get the sum of all positive nos. may be you
I dont get it, if its just the subset, then just get the sum of all positive nos. may be you wanted continous nos.another variation of the question can be, find the subset where (sum of subset)/(max element of the set) is maximum.
Lets discuss this as well :)Thanks,VijendraOn 4/5/06, shishir <[EMAI