Why wrong answerr?

@gagz23 please share the correct code for this problem

https://ide.codingblocks.com/s/315699 sorry

is there any other method to solve this problem this is quite lengthy i think…

hi @gagz23 you dont need the map, you are not even using it in the code.
The main logical error is that this code is giving wrong answer for the case “600 60” it should form “60600” but it actually forms “60060”
so you need to modify the compare function a bit

how to write the compare method? i have to compare vecctor of strings …idont knowhow to write fucniton for it.

hi @gagz23 to sort the vector of strings, you can sort it like:
the STL sort function should be called like this sort(v.begin(), v.end(), compare)
and the compare function should be like this:

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

thankyou soo much…

1 Like

@gagz23 dont forget to mark your doubt as resolved! :slight_smile: