the code is working fine with all the custom input cases and for other inputs as well but when I submit it , it doesn’t pass even one testcase.
Please help me in finding the bug in my code.
Can't find anything wrong in code
@raghav0712
Consider a case:
1
2
98 9
Expected O/p:
998
Your O/p:
989
Also a simple approach to this problem is by taking the input in the form of strings.
For this problem you can treat the array’s elements as strings and sort them in lexicographically decreasing order. For eg. [54, 546, 548, 60] if you sort these in lexicographically decreasing order result will be [60, 548, 546, 54] , then you can print all the elements and it will form the biggest number.
So take input in the form of string. Make your own custom comparator and sort accordingly.
The custom compare function must be something like this:
bool mycompare(string a,string b)
{
string ab=a+b;
string ba=b+a;
return ab>ba;
}
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.