<p>You are given an integer <code>num.</code> <strong>Rearrange</strong> the digits of <code>num</code> such that its value is <strong>minimized</strong> and it does not contain <strong>any</strong> leading zeros.</p>

<p>Return <em>the rearranged number with minimal value</em>.</p>

<p>Note that the sign of the number does not change after rearranging the digits.</p>

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

<pre>
<strong>Input:</strong> num = 310
<strong>Output:</strong> 103
<strong>Explanation:</strong> The possible arrangements for the digits of 310 are 013, 031, 103, 130, 301, 310. 
The arrangement with the smallest value that does not contain any leading zeros is 103.
</pre>

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

<pre>
<strong>Input:</strong> num = -7605
<strong>Output:</strong> -7650
<strong>Explanation:</strong> Some possible arrangements for the digits of -7605 are -7650, -6705, -5076, -0567.
The arrangement with the smallest value that does not contain any leading zeros is -7650.
</pre>

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

<ul>
	<li><code>-10<sup>15</sup> &lt;= num &lt;= 10<sup>15</sup></code></li>
</ul>

class Solution:
    def smallestNumber(self, num: int) -> int:
        # string s=to_string(abs(num));
        # if(num<0)
        # {
        #     sort(s.begin(),s.end());
        #     reverse(s.begin(),s.end());
        #     int n=stoi(s);
        #     return (-1)*n;
        # }
        # else
        # {
        #     sort(s.begin(),s.end());
        #     int i=0;
        #     while(s[i]=='0' && i<s.length())
        #     {
        #        i++; 
        #     }
        #     swap(s[i],s[0]);
        #     int n=stoi(s);
        #     return n;
        # }
        s=str(abs(num))
        if(num<0):
            s=sorted(s)
            s=s[::-1]
            st="".join(s)
            print(st)
            n=int(st)
            return -1*n
        else:
            s=sorted(s)
            i=0;
            while(i<len(s) and s[i]=='0'):
                i+=1
            if(i<len(s)):
                s[i],s[0]=s[0],s[i]
            st= "".join(s)
            n=int(st)
            return n
26