I have written this code it's working for the given test case but failing hidden cases

see this test case:
8
1 34 3 98 9 76 45 4
Expected Output
998764453341
correct Output
998764543431

Correct and Simplest approach for this problem


Logic:
we consider both the cases a+b and b+a as well
and then accordingly return true or false from compare function

NOTE:
int atoi (const char * str); Convert string to integer.
atoi takes char* and return integer corresponding to str
so in the code first i convert string to char* and then use atoi

i hope this helps
if your doubt is resolved don’t forgot to mark it as resolved