Sort strings, getting run error. But i dont find the error

#include <bits/stdc++.h>

using namespace std;
#define ll long long
bool compare(string a, string b)
{
int c=a.compare(b);
if(c==0 || c==1) return false;
else return true;
}
int main()
{ ll n;
cin>>n;

string *s = new string[n];
for(int i=0;i<n;i++)
{

    cin>>s[i];

}
sort(s,s+n,compare);
for(int i=0;i<n;i++)
{

    cout<<s[i]<<endl;

}

return 0;
}

@shashank3256 a.compare() isnt guaranteed to return 1 or -1, it will return a value > 0 or a value < 0 if the strings are not equal. It’d be better to use string::find() in this question

But it’s passing one test case. Though,will try this.

@shashank3256 i see you have passed all the test cases, please mark this doubt as resolved :slight_smile: