Design a function to determine the nth
super ugly number.
Super ugly numbers are positive integers whose prime factors are all contained in the given list of prime numbers factors
of length m
.
Example 1: Input: position = 10, factors = [3,5,7] Output: 35 Explanation: The sequence of super ugly numbers for the primes [3,5,7] starts as: [1,3,5,7,9,15,21,25,27,35] and the 10th number is 35. Example 2: Input: position = 8, factors = [2,11] Output: 44 Explanation: The super ugly numbers sequence for primes [2,11] is: [1,2,4,8,11,16,22,44] and the 8th number is 44.
m
≤ 80n
≤ 5×105factors
are prime numbers less than 1200nth
super ugly number will fit in a 32-bit signed integer