bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 2847. Smallest Number With Given Digit Product

2847. Smallest Number With Given Digit Product

Leetcode Solutions

Greedy Factorization Approach

  1. Check if n is 1, return '1' if true.
  2. Initialize an empty string result.
  3. Iterate from i = 9 down to i = 2: a. While n is divisible by i, divide n by i and prepend i to result.
  4. If n is greater than 1 after the loop, return -1.
  5. Return the result string.
UML Thumbnail

Backtracking Factorization Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...