<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>

class Solution {
    int cmp(int m, int n) {
        char c1[32];
        char c2[32];
        sprintf(c1,"%d%d", m, n);
        sprintf(c2,"%d%d", n, m);
        return strcmp(c1, c2);
    }
    void qs(vector<int>& nums, int s, int e) {
        if (s >= e)
            return;
        int l = s;
        int r = e;
        int m = nums[(l + r) / 2];
        while (l <= r) {
            while (cmp(nums[l], m) > 0)
                l++;
            while (cmp(nums[r], m) < 0)
                r--;
            if (l <= r) {
                swap(nums[l], nums[r]);
                l++;
                r--;
            }
        }
        qs(nums, s, r);
        qs(nums, l, e);
    }
public:
    string largestNumber(vector<int>& nums) {
        qs(nums, 0, nums.size() - 1);
        if (nums[0] == 0)
            return "0";
        string res;
        for (auto i:nums) {
            char c[32];
            sprintf(c, "%d", i);
            res += c;
        }
        return res;
    }
};
14400