0
Leetcode Problem 2847. Smallest Number With Given Digit Product
2847. Smallest Number With Given Digit Product
AI Mock Interview
Leetcode Solutions
Greedy Factorization Approach
Solution Idea
Algorithm Steps
Code Implementation
Complexity Analysis
Check if
n
is 1, return '1' if true.
Initialize an empty string
result
.
Iterate from
i = 9
down to
i = 2
: a. While
n
is divisible by
i
, divide
n
by
i
and prepend
i
to
result
.
If
n
is greater than 1 after the loop, return
-1
.
Return the
result
string.
Backtracking Factorization Approach
Ask Question
Programming Language
Purpose:
General Question
Debug My Code
image/screenshot of info
(optional)
[+]
Full Screen
Loading...
Get Answer
Suggested Answer
Answer
Full Screen
Copy Answer Code
Loading...