Smallest possible - MarisaOJ: Marisa Online Judge

Smallest possible

Time limit: 1000 ms
Memory limit: 256 MB
You are given an integer $n$. What is the smallest number you can have by rearranging digits in $n$? Note: Leading zeros is not allowed. ### Input - A single integer $n$. ### Output - Print an integer which is the largest number you can have. ### Constraints - $1 \le n \le 10^{5000000}$. ### Example Input: ``` 3210 ``` Output: ``` 1023 ``` **Bonus: Solve this problem using an algorithm with $\mathcal{O}(n)$ time complexity.**