Easy to understand (C++)
\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        vector<int> res(n);\n        res[0] = 1;\n        int p2=0,p3=0,p5=0;\n        for(int i=1;
```\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        vector<int> res(n);\n        res[0] = 1;\n        int p2=0,p3=0,p5=0;\n        for(int i=1;i<n;i++)\n        {\n            int mini = min(2*res[p2],min(3*res[p3],5*res[p5]));\n            res[i] =mini;\n            if(res[i]==res[p2]*2){\n                p2++;\n            }\n            if(res[i]==res[p3]*3){\n                p3++;\n            }\n            if(res[i]==res[p5]*5){\n                p5++;\n            }\n        }\n        return res[n-1];\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']