题目
https://leetcode-cn.com/problems/ugly-number-ii/
代码
class Solution {
public int nthUglyNumber(int n) {
if(n==1)
return 1;
int n2=0;
int n3=0;
int n5=0;
int[] dp=new int[n];
dp[0]=1;
for(int i=1;i<n;i++){
dp[i]=Math.min(dp[n2]*2,Math.min(dp[n3]*3,dp[n5]*5));
if(dp[i]==dp[n2]*2) n2++;
if(dp[i]==dp[n3]*3) n3++;
if(dp[i]==dp[n5]*5) n5++;
}
return dp[n-1];
}
}