677. Smallest Number With Given Digit Product

Give a positive integer n, and return a string that represents the smallest positive integer whose digit product equals n, or "-1" if there isn't one. 

Example 1:

Input : n = 75

Output : "355"

Explanation :

The product of 3 * 5 * 5 -> 75.

Example 2:

Input : n = 97

Output : "-1"

Explanation :

It can be shown that there is no number such that its product of digits is equal to 97. So the answer would be "-1".

Now Your Turn!

Pick the correct output for the given input

Input : n = 88

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 1018

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
string smallestNumber(long long n) {
//your code goes here
}
};
Test Case

Input:

N