# Leetcode 313 - Super ugly

`Note:`

- Use
`minHeap`

will TLE, so we stick to`DP`

. - Just like the other similar question
`LC 264`

. Create a bunch of`pointers`

for each`prime`

. - All pointers are initialized as
`0`

, which points at`dp[p]`

. - Iterate
`pointers[]`

and find the min by`dp[pVal] * prime`

. - For all qualified
`p`

, do`p++`

.

`Question:`

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.

`Example:`

1 | Input: n = 12, primes = [2,7,13,19] |

`Code:`

1 | /** |