<p>Given a list of non-negative integers <code>nums</code>, arrange them such that they form the largest number and return it.</p>

<p>Since the result may be very large, so you need to return a string instead of an integer.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [10,2]
<strong>Output:</strong> &quot;210&quot;
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,30,34,5,9]
<strong>Output:</strong> &quot;9534330&quot;
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 100</code></li>
	<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

vector<int> digits(int a){
        vector<int> ans;
        while(a > 0){
            ans.push_back(a % 10);
            a /= 10;
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
    

class Solution {
public:
    string postprocess(string s){
        if(s[0] == '0'){
            return "0";
        }
        return s;
    }
    string largestNumber(vector<int>& nums) {
        sort(nums.begin(), nums.end(), [](int a, int b){
            stringstream ss1, ss2;
            ss1 << a << b;
            ss2 << b << a;
            for(int i=0;i<ss1.str().size();++i){
                if(ss1.str()[i] == ss2.str()[i]){continue;}
                return ss1.str()[i] > ss2.str()[i];
            }
            return a > b;
        });

        stringstream ss;
        for(int num : nums){
            ss << num;
        }
        
        return postprocess(ss.str());
    }
};
15100