Form Biggest Number

How we i comparing strings of numbers in sorting function …

please dry run and explain that

1 – TESTCASE
2 – NUMBER OF ELEMENTS
14 – Number 1
19 – Number 2

how biggest no. can be formed…just want to know how strings of number after adding and compared ??

regards

hi @ManasxCOdE
we can use the STL sort function to sort all the strings such that
if we combine any 2 strings they should form the biggest number possible
so when we finally combine all such combinations, we get the biggest possible number.

hence the comparator function for sort function should be

bool compare(string s1, string s2) {
    return s1+s2 > s2+s1;
}

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.