I have checked over all test cases but on submitting it is throwing wrong answer. Please help me out by telling the edge cases for the problem.
FormBiggestNumber
Hello @Debugger,
Please, share your code. It will be easier for me to detect the issue.
Your output format would be wrong.
#include<bits/stdc++.h>
using namespace std;
bool compare(string a,string b)
{
return a>b;
}
int main() {
int t;
char ch;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
string s[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
stringstream str1;
str1<<(a[i]);
s[i] = str1.str();
}
sort(s,s+n,compare);
for(int i=0;i<n;i++)
{
cout<<s[i];
}
cout<<endl;
}
return 0;
}
Hello @Debugger,
Please, from the next time share it using Online Coding Blocks IDE: https://ide.codingblocks.com/
The way you have send it can introduce some syntax errors.
Steps:
- Paste it there.
- Save it.
- Share the URL generated.
Now, focusing on your code:
Your compare function is failing for the test cases like:
1
2
9 96
Expected Output:
996
Your Output:
969
I have modified your code:
Hope, this would help.
Give a like if you are satisfied.