Problem
Ask
Submissions

Problem: Super Ugly Number

Medium
30 min
Explore how to compute the n-th super ugly number, defined by prime factors from a given array, using k-way merge for efficient calculation. This lesson helps you understand the problem constraints, apply prime factorization logic, and implement the solution in Python to solve similar coding interview challenges.

Statement

Given an integer n and an array of distinct prime numbers primes, return the n-th super ugly number. A super ugly number is a positive integer whose only prime factors are from a given array primes.

The n-th super ugly number is guaranteed to fit within a 32-bit signed integer.

Constraints:

  • 11 \leq n 105\leq 10^5

  • 11 \leq primes.length 100\leq 100

  • 22 \leq primes[i] 1000\leq 1000

  • primes[i] is guaranteed to be a prime number.

  • All the values of primes are unique and sorted in an ascending order.

Problem
Ask
Submissions

Problem: Super Ugly Number

Medium
30 min
Explore how to compute the n-th super ugly number, defined by prime factors from a given array, using k-way merge for efficient calculation. This lesson helps you understand the problem constraints, apply prime factorization logic, and implement the solution in Python to solve similar coding interview challenges.

Statement

Given an integer n and an array of distinct prime numbers primes, return the n-th super ugly number. A super ugly number is a positive integer whose only prime factors are from a given array primes.

The n-th super ugly number is guaranteed to fit within a 32-bit signed integer.

Constraints:

  • 11 \leq n 105\leq 10^5

  • 11 \leq primes.length 100\leq 100

  • 22 \leq primes[i] 1000\leq 1000

  • primes[i] is guaranteed to be a prime number.

  • All the values of primes are unique and sorted in an ascending order.