题目:
题解:
func nthUglyNumber(n int) int {dp := make([]int, n+1)dp[1] = 1p2, p3, p5 := 1, 1, 1for i := 2; i <= n; i++ {x2, x3, x5 := dp[p2]*2, dp[p3]*3, dp[p5]*5dp[i] = min(min(x2, x3), x5)if dp[i] == x2 {p2++}if dp[i] == x3 {p3++}if dp[i] == x5 {p5++}}return dp[n]
}func min(a, b int) int {if a < b {return a}return b
}