Why does it have to be prime number?


  • 0
    D

    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?


  • 0

    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.


Log in to reply
 

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