Smallest Number with Given Digit Product
Given a positive integer 'N', find and return the smallest number 'M', such that the product of all the digits in 'M' is equal to 'N'. If such an 'M' is not possible or if 'M' cannot fit in a 32-bit signed integer, return 0.
Example:
Input:
N = 90
Output:
259
Explanation:
For 'N' = 90, the possible values for 'M' include 259 (2*5*9 = 90), 3352 (3*3*5*2 = 90), 2335 (2*3*3*5 = 90), and 952 (9*5*2 = 90), among others. The smallest possible 'M' is 259, hence, the answer is 259.
Constraints:
- 1 <= T <= 1000
- 1 <= N <= 109
- Time limit: 1 sec
Be the first one to answer
Add answer anonymously...
Top Hewlett Packard Enterprise Full Stack Developer interview questions & answers
Popular interview questions of Full Stack Developer
>
Hewlett Packard Enterprise Full Stack Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app