easy || generating a least number greater than previous ||cpp ||dp
```\n    int nthUglyNumber(int n) {\n        if(n==1){\n            return 1;\n        }\n        if(n==2){\n            return 2;\n        }\n        vector dp
```\n    int nthUglyNumber(int n) {\n        if(n==1){\n            return 1;\n        }\n        if(n==2){\n            return 2;\n        }\n        vector<int> dp(n+1);\n        map<int,int> ma;\n        for(int i=0;i<=n;i++){\n            if(i<=5){\n                dp[i]=i;\n            }\n            else{\n                int m=INT_MAX;\n                int k=3;\n                int p[3]={2,3,5};\n                while(k--){\n                    int j=ma[dp[i-1]/5];\n\t\t\t\t\t//just check the numbers from dp[i-1]/5 because less than that the number wont be greater than dp[i-1]\n\t\t\t\t\tint num=0;\n                    //cout<<dp[i-1]<<" ";\n                    while(num<=dp[i-1]&&j<n){\n                        num=dp[j]*p[k];\n                        //cout<<num<<" ";\n                        j++;\n                    }\n              \n                    m=min(num,m);\n                }\n                dp[i]=m;\n            }\n            ma[dp[i]]=i;\n        }\n        return dp[n];\n    }\n};
[]