Dividing array-----testcase not passing

Hello @guptarahul3100,

it is mentioned in the question that you have remove n/2 elements from A and add them to B and after doing that you can rearrange the elements in any order and you have to find minimum and maximum value of the difference between the array
A = 12, -3, 10, 0

For Maximum difference
A = 12,10
B = -3, 0
Diff (12 - (-3)) + (10 - 0) = 25

For Minimum difference
A = 0, 12
B = -3, 10
Diff = (0 - (-3)) + (12 - 10) = 5.

Approach:
sort the array, in case of minimum difference the adjacent elements will belong to a, b and in the case of maximum difference the first half subarry will be a, second half will be b

Now, check again your code and try to debug it on the basis of above mentioned approach.

Let me know if you still face any difficulty.
I’ll correct your code for you.

done the same can u see my code first!!!

Hey @guptarahul3100,

In that case the only problem i can think of is not satisfying the constraints mentioned in the question:
|Ai|<=10^9

I have corrected your code:

Hope, this would help.
Give a like if you are satisfied.

ok thnx
!!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.