i have checked o/p it is giving correct o/p for the testcases
still giving wrong answer on submission
I don't think anything is wrong with this code please help
bool compare(int a, int b)
{
string s1=to_string(a);
string s2=to_string(b);
return (s1+s2)>(s2+s1);
}
is the required code
for input
90 9
the required answer is 990
and not 909
return (s1+s2)>(s2+s1);
can you please explain this line
see
for input
90 9
if we use s1 > s2
then in that case the order we return is 90 followed by 9
but what is maximum 990
s1+s2 would give 909
s2+s1 will 990
so a combination of the 2 string is checked and the bigger is returned
in order to form the biggest number