264. Ugly Number II Medium

@problem@discussion
#Hash Table#Math#Dynamic Programming#Heap (Priority Queue)



1/**
2 * [264] Ugly Number II
3 *
4 * An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
5 * Given an integer n, return the n^th ugly number.
6 *  
7 * Example 1:
8 * 
9 * Input: n = 10
10 * Output: 12
11 * Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers.
12 * 
13 * Example 2:
14 * 
15 * Input: n = 1
16 * Output: 1
17 * Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	1 <= n <= 1690
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/ugly-number-ii/
28// discuss: https://leetcode.com/problems/ugly-number-ii/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn nth_ugly_number(n: i32) -> i32 {
34        0
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_264() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.