Python min/max heap solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def smallestNumber(self, num: int) -> int:
        placeholder = str(abs(num))
        zerocount = 0
        #if it is only one digit, then return it
        if len(placeholder) == 1:
            return num
        #initialise a min heap if it is positive
        elif num > 0:
            heap = [int(i) for i in placeholder]
        #or a max heap if it is negative
        else:
            heap = [-int(i) for i in placeholder]
        #convert to a heap
        heapify(heap)
        
        res = ''
        for _ in range(len(placeholder)):
            #pop the element of the min/max heap
            x = heappop(heap)
            if not x:
                zerocount += 1
            #append it to the resultant string
            res += (str(abs(x)))

        #if the number was positive
        if num > 0:
            #if it starts with 0
            if zerocount > 0:
                    first = res[zerocount]
                    return int(first + '0'*zerocount + res[zerocount+1:])
            
            else:
                return int(res)

        #if it was negative, then return a negative resultant string
        else:
            return -int(res)
```
['Python3']