Related to negative test cases

what we have to do when n is zero or negative
do we need to print anything or return from there?

Hello @mihir_4116 no n cant be negative in this:
and if n is zero means aapke array hi empty h then you will not continue with the logic because if array is empty then you will compare on which elements.
though you will not find any such test case.

#include
#include
#include
#include
using namespace std;
bool comparator(string a,string b){
if(b.size()<=a.size() && a.substr(0,b.size())==b){
return true;
}else if(a.size()<=b.size() && b.substr(0,a.size())==a){
return true;
}else{
return a<b;
}
}
int main() {
int n;
cin>>n;
vector v(n);
if(n==0){
return 0;
}else{
for(int i=0;i<n;i++){
string s;
cin>>s;
v.push_back(s);
}
sort(v.begin(),v.end(),comparator);
for(auto x:v)cout<<x<<endl;
}
}
its showing wrong answer. can you show me where i did wrong

Hello @mihir_4116 could you please share your code by saving it on ide.codingblocks.com

how to share code from coding blocks ide

go the link then paste your code and in that under file section you will see the save option after saving you have to share the link.

@mihir_4116 check now:

got it thanks
is there any whatsgroup that we have to join?
i enrolled in 1st april online premium batch

@mihir_4116 there should be option for that as well in your dashboard of the course.