Form Biggest Nummber

#include<bits/stdc++.h>
using namespace std;

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

}
int main() {

int T=0;
cin>>T;

for (int i= 0; i<T;i++)
{
	int N=0;
	cin>>N;
	int arr[10000];
	for(int j=0;j<N;j++)
	{
		cin>>arr[j];
		//cout<<arr[j];
	}
	
	sort(arr,arr+N,compare);

	for(int j=0;j<N;j++)
	{
		cout<<arr[j];
	}
		cout <<endl;
}
return 0;

}

I would like to know what is the problem in it ?

Consider a case:
1
2
98 9

Expected O/p:
998

Your O/p:
989

For this problem you can treat the array’s elements as strings and sort them in lexicographically decreasing order. For eg. [54, 546, 548, 60] if you sort these in lexicographically decreasing order result will be [60, 548, 546, 54] , then you can print all the elements and it will form the biggest number.
So take input in the form of string. Make your own custom comparator and sort accordingly.

The custom compare function must be something like this:
bool mycompare(string a,string b)
{
string ab=a+b;
string ba=b+a;
return ab>ba;
}

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.