here is my code:
it isn’t passing test cases but gives correct answer on custom input
Please Check the error in my code
hi @Garvit012
I am familiar with a similar method
i can share that with u
bool compare(string x, string y)
{
string xy = x.append(y);
string yx = y.append(x);
return xy.compare(yx) > 0 ? true : false;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n, v1 = 0, v2 = 0;
cin >> n;
string s[n];
cin.get();
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];
cout << endl;
}
}
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.