I need help with this problem

I have tried, but did not get the soln

hi @eragoncube_54c345cd154261dd do u know about sorting arrays using comparators?

Yes, I do. The problem I face here is that all testcases don’t pass with the current idea. I can’t figure out how to implement the conditions here.

hi @eragoncube_54c345cd154261dd cool buddy then u can refer this and tell me if any issue
refer code : https://ide.codingblocks.com/s/661893

do a dry run on paper for
n = 2
array elements --> 10 100

Thanks, I understood it

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.