Super Easy C++ Code


#1

bool compare(int x,int y) {
string st1 = to_string(x);
string st2 = to_string(y);
return (st1+st2)>(st2+st1);
}
string Solution::largestNumber(const vector &A) {
vector B = A;
sort(B.begin(),B.end(),compare);
bool flag=true;
for(int x:B) {
if(x==0&&flag) continue;
cout<<x;
flag=false;
}
if(flag) return “0”;
return “”;
}