/bin/run.sh: line 4: 18 Killed ./exe …how to handle this code.
Error showing while compiling code
https://ide.geeksforgeeks.org/0koMRhmA3P . could you also tell me what’s the error as it has only passed testcase 1 .
your code has no error like this
and
for this input
3
batman
bat
apple
your code output
apple
bat
batman
correct one
apple
batman
bat
your logic of compare function is not correct
use can use this
bool compare(string s1,string s2){
int i=0;
while(s1[i]==s2[i]&&i<s1.length()-1&&i<s2.length()-1){
i++;
}
if(s1[i]==s2[i]) return true;
return s1<s2;
}
first try to understand it at your own