Problem
Submissions
Leaderboard
Solution
Nishant is a very naughty boy in Launchpad Batch. One day he was playing with strings, and randomly shuffled them all. Your task is to help Nishant Sort all the strings ( lexicographically ) but if a string is present completely as a prefix in another string, then string with longer length should come first. Eg bat, batman are 2 strings and the string bat is present as a prefix in Batman - then sorted order should have - Batman, bat.https://ide.codingblocks.com/s/611427
Not Passing Testcase //please Help
hey the condition you have wrote is not right in your compare function, do it like this
if(a.size() <= b.size() && b.substr(0, a.size())==a){
return a.size()>=b.size();
}
else if(b.size() <= a.size() && a.substr(0, b.size())==b){
return a.size()>=b.size();
}
take reference from this
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.