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

Return the rearranged number with minimal value.

Note that the sign of the number does not change after rearranging the digits.

&nbsp;
Example 1:

Input: num = 310
Output: 103
Explanation: 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.


Example 2:

Input: num = -7605
Output: -7650
Explanation: 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.


&nbsp;
Constraints:


	-1015 &lt;= num &lt;= 1015


class Solution:
    def smallestNumber(self, num: int) -> int:
        lst=[i for i in str(num)]
        if num<0:
            return ''.join(['-'] + sorted(lst[1:],reverse=True))
        lst=sorted(lst)
        if '0' in lst:
            itr=0
            while itr<len(lst) and lst[itr]=='0':
                itr+=1
            if itr==len(lst): #All zeroes
                return ''.join(lst)
            return ''.join([lst[itr]]+lst[:itr]+lst[itr+1:])
        return ''.join(lst)
class Solution {
    public long smallestNumber(long num) {
        if(num == 0){
            return 0;
        }
        boolean isNegative = num < 0;
        num  = num < 0 ? num * -1 : num;
        
        char[] c = String.valueOf(num).toCharArray();
        Arrays.sort(c);
        String str;
        if(!isNegative){
            int non = 0;
			//if not negative we need to find out the first non-leading zero then swap with first zero
            for(; non < c.length; non++){
                if(c[non] != '0'){
                    break;
                }
            }
            char temp = c[non];
            c[non] = c[0];
            c[0] = temp;
            str = new String(c);
        }else{
            str = new String(c);
            StringBuilder sb = new StringBuilder(str);
            str = "-".concat(sb.reverse().toString());
        }
        return Long.valueOf(str);
    }
}
class Solution
{
public:
    long long smallestNumber(long long num)
    {
        if (num < 0)
        {
            string s = to_string(-num);
            sort(s.rbegin(), s.rend());
            return -stoll(s);
        }
        else if (num == 0)
            return 0;
        string s = to_string(num);
        sort(s.begin(), s.end());
        int i = 0;
        while (s[i] == '0')
            i++;
        char c = s[i];
        s.erase(s.begin() + i);
        s = c + s;
        return stoll(s);
    }
};
var smallestNumber = function(num) {
    let arr = Array.from(String(num));
    if(num>0){
    arr.sort((a,b)=>{
         return a-b;
    })
    }
    else{
         arr.sort((a,b)=>{
              return b-a;
         })
    }
    for(let i=0;i<arr.length;i++){
       if(arr[i]!=0){
            [arr[0],arr[i]]=[arr[i],arr[0]];
            break;
       }
  }
    return arr.join("");
};
Smallest Value of the Rearranged Number