Practice Super Ugly Number
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of integers primes, return the nth super ugly number. The nth super ugly number is guaranteed to fit in a 32-bit signed integer.
Source: Super Ugly Number on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 12, primes = [2,7,13,19]
Output
32
# Example 2
Input
n = 1, primes = [2,3,5]
Output
1
Constraints
1 <= n <= 10^5
1 <= primes.length <= 100
2 <= primes[i] <= 1000
primes[i] is guaranteed to be a prime number.
All the values of primes are unique and sorted in ascending order.
Related LeetCode Problems
Practice more problems similar to Super Ugly Number.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.