C++ solution with explaination (DP) approach
DP approach \n using Tabulation \n O(N) time complexity \n\n\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        int dp[n+1]; // initialize dp a
* **DP approach** \n*  **using Tabulation** \n* **O(N) time complexity** \n\n```\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        int dp[n+1]; // initialize dp array with n+1\n        dp[1] =1;\n        int p2 =1, p3 = 1, p5 = 1;// pointer p2 is for 2, p3 for 3, p5 for 5\n        for(int i =2; i<= n ; i++){\n            int f2 =  2* dp[p2]; \n            int f3 = 3* dp[p3];\n            int f5 = 5* dp[p5];\n            int min_ = min(f1, min(f2, f3)); // find the min  of all \n\t\t\t//suppose p2, p3 & p5 are at dp[0]  f2 will be  2* 1 , 3*1 , 5*1 \n            dp[i] = min_; // store the next dp[1] to the minimum of all (f2, f3, f5)\n\t\t\t//after storing the minimum \n            if(min_ == f2) p2++; // increment if f2 is min\n            if(min_ == f3) p3++;// increment if f3 is min\n            if(min_ == f5) p5++;// increment if f5 is min\n         }\n        return dp[n]; // return dp of n\n    }\n};\n```\n***comment if have doubt and do upvote***
['Dynamic Programming', 'C', 'C++']