<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 largestNumber(vector<int>& nums) 
    {
        string ans = "";
        vector<string>arr;

        for(int i = 0 ; i < nums.size() ; i++)
        arr.push_back(to_string(nums[i]));

        sort(arr.rbegin() , arr.rend() , [&](auto const &a , auto const &b ){
            

            return a+b < b+a;


            // int s1 = 0; 
            // while(s1<a.size() && s1 < b.size())
            // {
            //     if(a[s1] < b[s1] )
            //     return 1;

            //     s1++;
            // }

            // if(s1 == a.size())
            // {
            //     while(s1<b.size())
            //     {
            //         if(b[s1] != '0')
            //         return 1;
            //         s1++;
            //     }

            //     return 0;
            // }

            // else
            // {
            //     while(s1 < a.size())
            //     {
            //         if(a[s1] != '0')
            //         return 0;
            //         s1++;
            //     }

            //     return 1;            
            // }
        } );

        for(int i = 0 ; i < nums.size() ; i++)
        {
            if(ans.size() == 0 && arr[i] == "0")
            continue;

            ans+=arr[i];
        }

        if(ans.size() == 0)
        return "0";
        return ans;

    }
};
17600