标签:get div ini max turn flow == etc minimum
public class Solution { public int smallestFactorization(int a) { if (a < 10) { return a; } List<Integer> factor = new ArrayList<>(); for (int i = 9; i > 1; i--) { while (a % i == 0) { factor.add(i); a = a / i; } } if (a != 1) { return 0; } long result = 0; // otherwise, overflow for (int i = factor.size() - 1; i >= 0; i--) { result = result * 10 + factor.get(i); if (result > Integer.MAX_VALUE) { return 0; } } return (int)result; } }
[LeetCode] 625. Minimum Factorization
标签:get div ini max turn flow == etc minimum
原文地址:http://www.cnblogs.com/chencode/p/minimum-factorization.html