Not one of the test case pass. It’s something wrong with the code or I am doing this with vector that’s why it is wrong.
Why None of the test case passes?
declare a new
vector v;
for each test case
move this statement inside while(t–)
Still not passing anyone of the test cases.
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
bool Compare(string a, string b){
string ab = a.append(b);
string ba = b.append(a);
return ab.compare(ba) > 0 ? true : false;
}
int main() {
int t;
cin>>t;
while(t--){
int size;
cin>>size;
vector<string> v;
for(int i=0;i<size;i++){
string d;
cin>>d;
v.push_back(d);
}
sort(v.begin(),v.end(),Compare);
for(int i=0;i<size;i++){
cout<<v[i];
}
cout<<endl;
}
return 0;
}
code worked fine for me
Yeah, there is a problem with editor First it doesn’t work but after multiple refreshes it worked.
Thanx!
1 Like