313. Super Ugly Number Medium

@problem@discussion
#Array#Math#Dynamic Programming



1/**
2 * [313] Super Ugly Number
3 *
4 * A super ugly number is a positive integer whose prime factors are in the array primes.
5 * Given an integer n and an array of integers primes, return the n^th super ugly number.
6 * The n^th super ugly number is guaranteed to fit in a 32-bit signed integer.
7 *  
8 * Example 1:
9 * 
10 * Input: n = 12, primes = [2,7,13,19]
11 * Output: 32
12 * Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes = [2,7,13,19].
13 * 
14 * Example 2:
15 * 
16 * Input: n = 1, primes = [2,3,5]
17 * Output: 1
18 * Explanation: 1 has no prime factors, therefore all of its prime factors are in the array primes = [2,3,5].
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= n <= 10^5
24 * 	1 <= primes.length <= 100
25 * 	2 <= primes[i] <= 1000
26 * 	primes[i] is guaranteed to be a prime number.
27 * 	All the values of primes are unique and sorted in ascending order.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/super-ugly-number/
33// discuss: https://leetcode.com/problems/super-ugly-number/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn nth_super_ugly_number(n: i32, primes: Vec<i32>) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_313() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.