Smallest Value Of The Rearranged Number(Direct Solution)
Code
# Code
```java []
class Solution {
    public long smallestNumber(long num) {
        if(num>0){
            List<Integer> l=new ArrayList<>();
            int count=0;
            while(num!=0){
                if(num%10!=0){
                    l.add((int)(num%10));
                }
                else{
                    count++;
                }
                num/=10;
            }
            Collections.sort(l);
            while(count--!=0){
                l.add(1,0);
            }
            long zz=0;
            for(int i:l){
                zz*=10;
                zz+=i;
            }
            return zz;
            
        }
        List<Integer> l=new ArrayList<>();
            int count=0;
            while(num!=0){
                if(num%10!=0){
                    l.add(-(int)(num%10));
                }
                else{
                    count++;
                }
                num/=10;
            }
            Collections.sort(l);
            Collections.reverse(l);
            while(count--!=0){
                l.add(0);
            }
            long zz=0;
            for(int i:l){
                zz*=10;
                zz+=i;
            }
            return zz*-1;
        
    }
}
```
['Java']