Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

So far I know the O(nk) and O(nlogk) solution, which basically choose the next ugly number from k candidates.

But why does it have to be a prime number list for input? Any example that would fail if the input is not prime number?

I'm not sure what you mean. For the coding problem itself, there is no need to restrict the factors to be prime numbers, any positive numbers are fine.

But to make the problem more meaningful in real life, we prefer to consider prime factors.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.