Code for this qstn

#include
#include<bits/stdc++.h>

#include
using namespace std;

bool cmp(int a,int b)
{
if(a>b)
return a>b;
else
return b>a;
}

/bool compar(int a,int b)
{
int s,r;
int A=a,B=b;
while(a%10==a)
{
a=a/10;
}
s=a;
while(b%10==b)
{
b=b/10;
}
r=b;
if(s<r)
return b>a;
else
return a>b;
if(s==r)
{
return cmp(A,B);
}
}
/

bool compar(int a,int b)
{
int c1=0,c2=0;
while(a>0)
{
c1++;
a/=10;
}
while(b>0)
{
c2++;
b/=10;
}
c1–;
c2–;
int a1=a/(pow(10,c1));
int b1=b/(pow(10,c2));
if(a1>b1)
{
return a>b;
}
else
return b>a;
if(a1==b1)
{
return cmp(a,b);
}
}

void funct(int a[],int n)
{
sort(a,a+n,compar);
for(int i=n-1;i>=0;i–)
{

	cout<<a[i];
}

}

int main() {

int t,n,a[100];
cin>>t;
while(t--)
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	funct(a,n);
}
return 0;

}

you’ve made this code too complex all you need to do is take input as string and compare on the basis of if s1 + s2 > s2 + s1.
Code

how to understand that input should be taken as string when constraints are given for int

since the question mentions that concatenation is involved and since it is easier to concatenate string then integers it is a good idea to use strings instead of integers.

yea its complex but if we want to take the input in the form of integer then how to solve it?