LeetCode "Super Ugly Number" !

A classic type of problem: multi-pointer marching algorithm. For each pointer of each prime, we need to remember where it is in the ugly sequence, so that we can proceed properly. 
The SAME thought as "Ugly Number II" (https://leetcode.com/discuss/55304/java-easy-understand-o-n-solution)

Non-Heap based: https://leetcode.com/discuss/72835/108ms-easy-to-understand-java-solution
Heap-based: https://leetcode.com/discuss/74284/c-300ms-solution
Actually they are the same.

Key Idea of these two problems is: new ugly number can only be produced from previous ugly number.

 

你可能感兴趣的:(LeetCode "Super Ugly Number" !)