<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 {
public:
    string numToString(int n){
        string s="";
        if(n==0){
            s+='0';
        }
        while(n){
            s+=char(n%10+'0');
            n/=10;
        }
        reverse(s.begin(),s.end());
        return s;
    }
    
    string largestNumber(vector<int>& nums) {
        int n=nums.size(),i,j,k;
        vector<string>a;
        for(i=0;i<n;i++){
            a.push_back(numToString(nums[i]));
        }
        for(i=0;i<n;i++){
            for(j=1;j<n-i;j++){
                if(a[j-1]+a[j]<a[j]+a[j-1]){
                    swap(a[j-1],a[j]);
                }
            }
        }
        string ans="";
        if(a[0]=="0"){
            ans+='0';
            return ans;
        }
        for(i=0;i<n;i++){
            ans+=a[i];
        }
        return ans;
    }
};
14700