Dividing Array - greedy problem

sample input is giving right ans but testcases are failing .according to my logic .

mindiff = max(firstarray)-max(secondarray)

maxdiff = max(firstarray)-min(secondrray)

ide: https://ide.codingblocks.com/s/180649

Hey @Vishal123
Here is your modified code for reference : https://ide.codingblocks.com/s/180934
If your doubt is resolved please mark it as closed.

what is the problem in my code

Your logic isn’t correct. See the code once you’ll know.

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.