LeetCode 264, Medium. Topics: Hash Table, Math, Dynamic Programming, Heap (Priority Queue). View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:
Problem
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
Given an integer n, return the nth * ugly number*.
Examples
Constraints
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026