Simple java solution and easier to understand, beats 100%. Prefers simple maths over stringbuilders
IntuitionSimple and easy to understand, beets 100%
Tried abother solution with StringBuilder instead of res variable multiply and addition, but the percentage d
# Intuition
Simple and easy to understand, beets 100%
Tried abother solution with StringBuilder instead of res variable multiply and addition, but the percentage d=decreased to 78%. Stringbuilder solution was proposed by ChatGpt but mine solution is beating 100%. 

# Code
```java []
class Solution {
    public long smallestNumber(long num) {
        int[] arr = new int[10];
        boolean isNegative = num < 0;
        num = Math.abs(num);
        while (num != 0) {
            arr[(int) (num % 10)]++;
            num /= 10;
        }
        long res = 0;
        if (isNegative) {
            for(int i=9; i>=0; i--) {
                while (arr[i] > 0) {
                    res = res * 10 + i;
                    arr[i]--;
                }
            }
        } else {
            for (int i = 1; i < 10; i++) {
                if (arr[i] > 0) {
                    res += i;
                    arr[i]--;
                    break;
                }
            }
            for (int i = 0; i < 10; i++) {
                while (arr[i] > 0) {
                    res = res * 10 + i;
                    arr[i]--;
                }
            }
        }
        return isNegative? -res : res;

    }
}
```
['Java']