136 - Ugly Numbers

You may solve this problem with best-first search.

You may think of all ugly numbers connected as a graph. Two ugly numbers are connected if one is a multiple of 2, 3, or 5 of the other; for example, 1 and 2 are connected, and 3 and 6 are connected. And you search this graph (starting from 1) until you visit the 1500-th node via a best-first search that smaller nodes are searched first.

Here is a reference solution.

Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.