1. 题目
2. 题解
class Solution {
public int nthUglyNumber(int n) {
int a = 0, b = 0, c = 0;
int[] dp = new int[n];
dp[0] = 1;
for(int i = 1; i < n; i++){
int l1 = dp[a] * 2;
int l2 = dp[b] * 3;
int l3 = dp[c] * 5;
dp[i] = Math.min(Math.min(l1, l2), l3);
if(dp[i] == l1)
a++;
if(dp[i] == l2)
b++;
if(dp[i] == l3)
c++;
}
return dp[n - 1];
}
}