Doubt in my approach

In this question I was thinking to compare each consecutive numbers of the array. I want to compare these numbers on the basis of each digit. This comparison is similar to dictionary comparison where we compare two strings lexicographically. But here I want to perform this on the digits and sort the array. How should I proceed ? Is there any other approach ?

hello @yashsharma4304 you are someway thinking correct .
you can make your custom sort function and in that you can make comparison by appending each number to other and return the biggest of them .


if you have any you can ask here .
Happy Learning !!

1 Like

can’t we do this thing by taking an integer array instead of string array ? And why we are returning
a+b> b+a in compare function.

yes you can do by integer array as well .
this is because you have to form the biggest number possible so for that we are appending and checking from which side the biggest number will be formed .

1 Like