Java: Beats 100%
Beats 100%\n\n\n\n# Code\n\nclass Ugly{\npublic int[] nums = new int[1690];\nUgly(){\n    nums[0] = 1;\n    int ugly,i2 = 0,i3=0,i5=0;\n\n    for(int i=1;i<1690
Beats 100%\n![Screenshot 2024-05-09 164355.png](https://assets.leetcode.com/users/images/44e88a5a-f4db-449e-8a15-1845543cee3d_1715253244.1048074.png)\n\n\n# Code\n```\nclass Ugly{\npublic int[] nums = new int[1690];\nUgly(){\n    nums[0] = 1;\n    int ugly,i2 = 0,i3=0,i5=0;\n\n    for(int i=1;i<1690;i++){\n        ugly = Math.min(Math.min(nums[i2]*2,nums[i3]*3),nums[i5]*5);\n        nums[i] = ugly;\n\n        if(ugly == nums[i2]*2) ++i2;\n        if(ugly == nums[i3]*3) ++i3;\n        if(ugly == nums[i5]*5) ++i5;\n        \n    }\n}\n}\nclass Solution {\n    public static Ugly u = new Ugly();\n    public int nthUglyNumber(int n) {\n        return u.nums[n-1];\n    }\n}\n```
['Java']