class Solution {
public:
string largestNumber(vector<int>& nums) {
if(all_of(nums.begin(), nums.end(), [](int num){return num==0;})){return "0";}
vector<string> arr;
for(auto& val: nums){
arr.push_back(to_string(val));
}
sort(arr.begin(), arr.end(), [](string& s1, string& s2){return s1+s2>s2+s1;});
string ans;
for(auto& val: arr){
ans += val;
}
return ans;
}
};
class Solution(object):
def largestNumber(self, nums):
"""
:type nums: List[int]
:rtype: str
"""
ans = "".join(sorted(map(str, nums),lambda x,y: [1,-1][x+y>y+x]))
return ans if ans[0]!='0' else "0"