✅ java || with comments || DP
\nclass Solution {\n    public int nthUglyNumber(int n) {\n        //1. Instantiate an array for holding the results\n        int[] dp = new int[n+1];\n        
```\nclass Solution {\n    public int nthUglyNumber(int n) {\n        //1. Instantiate an array for holding the results\n        int[] dp = new int[n+1];\n        \n        dp[1]=1;\n        // 2.Create three index pointers pointing to different positions of the array.\n        int p2=1;\n        int p3=1;\n        int p5=1;\n        \n    \n        for(int i =2 ;i<=n;i++)\n        {\n           int f1 = 2* dp[p2];\n           int f2 = 3* dp[p3];\n           int f3 = 5* dp[p5];\n            \n        // 3.Since we are not using a priority Queue, we need\n        // to keep track of the minimum value and append to the result ourselves.\n            int min = Math.min(f1,Math.min(f2,f3));\n            dp[i]=min;\n            \n            \n            \n    // 4.If any of the above the value is the minimum value of the three,\n    // then we move the corresponding pointer to calculate the next iteration\n    // These pointers help us keep track of the ascending order and ensure\n    // each value we put in the result is indeed in a sorted order.    \n            if(min==f1)\n            {\n                p2++;\n            }\n            if(min==f2)\n            {\n                p3++;\n            }\n            if(min==f3)\n            {\n                p5++;\n            }\n        }\n        return dp[n];\n        //5.The last element of the result array is the nth prime factor number we want.\n    }\n}\n```\n**Give it a upvote if you like it (:**
['Dynamic Programming', 'Java']