the output is comin out to be fine with this code yet not able to submit the code. Also why can’t i use ‘stoi’ or ;‘atoi’ forn converting a constant character string to int??
#include
#include
#include
#include
#include<bits/stdc++.h>
using namespace std;
int myCompare(string X, string Y)
{
string XY = X.append(Y);
string YX = Y.append(X);
return XY.compare(YX)>0?1:0;
}
string rearrange(vectorv)
{
string s = “”;
sort(v.begin(),v.end(),myCompare);
int m = v.size();
for(int i=0 ;i<m; i++)
s=s.append(v[i]);
return s;
}
int main() {
vectorv;
int arr[100];
int t;
cin>>t;
int n;
while(t–)
{
cin>>n;
for(int i=0; i<n; i++)
{
cin>>arr[i];
v.push_back(to_string(arr[i]));
}
string s = (rearrange(v));
for(int i=0;s[i];i++)
cout<<s[i]-‘0’;
}
return 0;
}