Form Biggest number


this code is working fine with the custom test cases but not passing even 1 test case in ArrayProblem Section

why??

hi @dare_devil_007
see for the input
1
2
60 600

the output should be 60600
but your output is coming out to be 60060

1 Like

if(l1!=l2){
int i(0),j(0);
while(l1!=0 and l2!=0){

	int m = a[i++]-'0';
	int n = b[j++]-'0';
	if(m==n)
		continue;
	return m>n;


}

return a<b;

}

this logic should just work fine but why it is’nt working?

@dare_devil_007 there is a really simple way to do this

bool compare(string a, string b){
    return a+b > b+a;
}
1 Like

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

bool compare(string a, string b){
return a+b > b+a;
}
int main() {
int T;
cin >> T;
while(T–){
int n;
cin >> n;
string numbers[n];
for(int i=0;i<n;i++){
cin >> numbers[i];
}

	sort(numbers,numbers+n,compare);
    for(int i=0;i<n;i++) cout<<numbers[i];

    cout<<endl;

}
return 0;

}

this code still not passing even one TC

hi @dare_devil_007 I cant see this code in your submissions, can you try again?