[Python3] Using Frequencies | Handling negative and postives sep
\tclass Solution:\n\t\tdef smallestNumber(self, num: int) -> int:\n\t\t\tfrequency = [0]10\n\t\t\tisPos = True if num > 0 else False\n\t\t\tnum = abs(num)\n\n\t
\tclass Solution:\n\t\tdef smallestNumber(self, num: int) -> int:\n\t\t\tfrequency = [0]*10\n\t\t\tisPos = True if num > 0 else False\n\t\t\tnum = abs(num)\n\n\t\t\twhile num:\n\t\t\t\td=num%10\n\t\t\t\tfrequency[d]+=1\n\t\t\t\tnum=num//10\n\n\t\t\tans = 0\n\t\t\tif isPos:\n\t\t\t\tfor i in range(1, 10):\n\t\t\t\t\tif frequency[i]>0:\n\t\t\t\t\t\tans = i\n\t\t\t\t\t\tfrequency[i] -= 1\n\t\t\t\t\t\tbreak\n\t\t\t\tfor i in range(0, 10):\n\t\t\t\t\twhile frequency[i]:\n\t\t\t\t\t\tans = ans* 10 + i\n\t\t\t\t\t\tfrequency[i] -= 1\n\t\t\telse:\n\t\t\t\tfor i in range(9, 0, -1):\n\t\t\t\t\tif frequency[i]>0:\n\t\t\t\t\t\tans = i\n\t\t\t\t\t\tfrequency[i] -= 1\n\t\t\t\t\t\tbreak\n\t\t\t\tfor i in range(9,-1, -1):\n\t\t\t\t\twhile frequency[i]:\n\t\t\t\t\t\tans = ans* 10 + i\n\t\t\t\t\t\tfrequency[i] -= 1\n\n\t\t\treturn ans if isPos else -ans
['Array', 'Python', 'Python3']