625. Minimum Factorization

Posted jxr041100

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了625. Minimum Factorization相关的知识,希望对你有一定的参考价值。

Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a

If there is no answer or the answer is not fit in 32-bit signed integer, then return 0.

Example 1
Input:

48 

Output:

68

 

Example 2
Input: 

15

Output:

35
class Solution {
public:
    int smallestFactorization(int a) {
        if (a < 2) return a;
        string s;
        for (int i = 9; i >= 2; i--) {
            while (a % i == 0) {
                s.insert(s.begin(), (0 + i));
                a /= i;
            }
        }
        return (a > 1 || s.size() > 10 || stol(s) > INT_MAX) ? 0 : stoi(s);
    }
};

 

以上是关于625. Minimum Factorization的主要内容,如果未能解决你的问题,请参考以下文章

[LeetCode 625] Minimum Factorization

[leetcode-625-Minimum Factorization]

[LeetCode] 625. Minimum Factorization

LeetCode Minimum Factorization

使用 SD 卡将 xap 文件安装到 Lumia 625

MTK X20和高通625哪个好?