Search⌘ K
AI Features

Super Ugly Number

Understand how to find the nth super ugly number whose prime factors come from a given array. Explore techniques using k-way merge algorithms and learn to implement an efficient solution to this problem. Practice coding this pattern to strengthen your interview preparation.

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 ...