class Solution {
public int nthUglyNumber(int n) {int[] nums = new int[n];//初始化数组int index2 = 0;int index3 = 0;int index5 = 0;int tmp = 1;nums[0] = 1;//初始化第一个值,当n等于1的时候直接是1int cnt = 1;while (cnt < n) {tmp = Math.min(nums[index2] * 2, Math.min(nums[index3]* 3, nums[index5] * 5));//寻找这几个中最小的nums[cnt++] = tmp;if (tmp == nums[index2] * 2) {index2++;}if (tmp == nums[index3]* 3) {index3++;}if (tmp == nums[index5] * 5) {index5++;}}return nums[n-1];}
}