C++ Efficient solution Easy way with comments
class Solution {\npublic:\n\n    int nthUglyNumber(int n) {\n        vectorans(n);\n        ans[0]=1; //1 will always be there\n        int two=0,three=0,five=0
class Solution {\npublic:\n\n    int nthUglyNumber(int n) {\n        vector<int>ans(n);\n        ans[0]=1; //1 will always be there\n        int two=0,three=0,five=0; //these are the pointer to keep a track\n        for(int i=1;i<n;++i){\n            int multwo = ans[two]*2;\n            int multhree = ans[three]*3;\n            int mulfive = ans[five]*5;\n            ans[i] = min(multwo,min(multhree,mulfive)); //taking minimum of all the three above\n\t\t\t// incrementing the pointer whose value was found minimum\n            if(ans[i]==multwo) two++;\n            if(ans[i]==multhree) three++;\n            if(ans[i]==mulfive) five++;\n        }\n        return ans[n-1];\n    }\n};\n//if like\n//doupvote\n//happy coding :)
['Dynamic Programming', 'C']