@ sunny
is there any reason for splitting the array in ur manner ??
and what abt the complexity ??
i think each time u exchange b/w A and B it takes O(n*n)
so u have complexity O(no_of_exchanges*n*n)
O(n^2) solution
sort the array...O(nlogn)
S=total sum
search for that continous su
there is some problem , i mean you taken some assumptions here. in first
caes 1 and 4 have difference of 3 which is not less than 2 , am i missing
something. also , if we have two replacement values , which will we replace
, i mean excahnge if there are two chocies . I think your algo might work
wi
How about this algorithm:
1 sort the given array in ascending order
2 traverse from back that is greater to smaller
3 put the 1st read in arrayA and the 2nd read in arrayB
4 put the 3rd read in arrayB and the 4th read in arrayA (notice we
have reverse the order of putting the values)
5 repeat the
Your solution does not consider the fact that the two subsets have
equal elements(50 elements each)
You have provided a solution for http://www.spoj.pl/problems/FCANDY/
But this question is different. It is similar to
http://www.codechef.com/problems/TEAMSEL/
On Dec 29, 10:56 pm, vishal raja wro