Failing testcases

#include
#include
#include
#include
using namespace std;
bool comp(int a,int b)
{

string s1=to_string(a);
string s2=to_string(b);

int a1=stoi(s1+s2);
int a2=stoi(s2+s1);

return a1>a2;

}
int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;

int arr[n];
for(int i=0;i<n;++i)
cin>>arr[i];

sort(arr,arr+n,comp);

for(int i=0;i<n;++i)
cout<<arr[i];
cout<<endl;
}
return 0;

}

Hello @diamond_saroha first you are taking the array as integer and then you are cinverting it into string array then why not you take the input as of string array only.
this is the corrected code:


if you have any doutbt you can ask here:
Happy Learning!!

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.