Everytime wrong answer : "Form Biggest Number"

I have been taking inputs in the string and checking them lexicographically. I don’t know why every time output is the wrong answer. my other inputs work fine.

#include <bits/stdc++.h>
using namespace std;
bool compare(string a,string b)
{
return a>b;
}
int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
vector arr;
for(int i=0;i<n;i++)
{
string ok;
cin>>ok;
arr.push_back(ok);
}
sort(arr.begin(),arr.end(),compare);
for(int i=0;i<n;i++)
{
cout<<arr[i];
}
}
return 0;
}

@wilson.nagar hey wilson your compare function is not correct change with this compare function and you are done
int mycompare(string x, string y)
{
string xy=x.append(y);
string yx=y.append(x);
return xy.compare(yx)>0 ?1 :0;
}

TestCase 1: wrong answer again :confused:

The code works correctly during custom inputs, and the compare function works too.
but on submitting, it gives wrong answer… please recheck

@wilson.nagar hey wilson your code is not given right answer for this case
8
1 34 3 98 9 76 45 4
expected output 998764543431
but your output
989764543431
so please update your code with compare function with the suggest one

I worked on the suggested code previously and understood the difference.
but in the updated code too gives wrong answer

@wilson.nagar hey wilson use endl after each test case otherwise you will get wrong answer

wow…
Thank you :smile:

Hey @wilson.nagar, if your doubt is resolved please mark it as resolved in your course’s “ Ask Doubt ” section. You can reopen it if required.