Dividing subarray code blocks

I am failing the test cases, could you tell me what is wrong in my code.

Hello @nimit_jain could you please explain your logic here:
because i think you logic is not correct.
after sorting the array in case of min it is like the adjacent elements elemtns should be there in the diffrent arrays and int he case of the maximum the starting element should be in the a array suppose then the ending element would be in the b array, 2nd element in the a array and the second last element in the b array.
Here for your reference i am attaching the code:


if you have any doubt you can ask here:
Happy Learning!!

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.