Neat and Easy C++ DP solution
\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        //check the base case ( n can not be less than 1)\n        if(n==1){\n            return 1;
```\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        //check the base case ( n can not be less than 1)\n        if(n==1){\n            return 1;\n        }\n        vector <int> ans(n);\n        //store all the ans in this vector\n        ans[0]=1;\n        int two=0,three=0,five=0;\n        for(int i =1;i<n;i++){\n            ans[i]=min(ans[two]*2,min(ans[three]*3,ans[five]*5));\n            \n            if(ans[i]==ans[two]*2)two++;\n            if(ans[i]==ans[three]*3)three++;\n            if(ans[i]==ans[five]*5)five++;\n        }\n        return ans[n-1];\n    }\n};\n\n\n```\n
['Dynamic Programming', 'C++']