Please enter your email address or userHandle.
Given a positive integer N, find the smallest number S such that the product of all the digits of S is equal to the number N. If there's no such number, Print "-1".
N = 100
4*5*5 = 100. There are no numbers
less than 455 with the product of
it's digit as 100.
N = 26
There are no numbers which can form
a product of 26 with its digits.
You don't need to read input or print anything. Your task is to complete the function getSmallest() which takes an Integer N as input and returns the answer as a String.
Expected Time Complexity: O(log(N))
Expected Auxiliary Space: O(1)
1 <= N <= 109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
want to view the editorial?
Login to access your submissions.