✅💯🔥Explanations No One Will Give You🎓🧠Very Detailed Approach🎯🔥Extremely Simple And Effective🔥
\n\n\n# Code\n\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        int un1 = 1;\n        int un2 = 1;\n        int un3 = 1;\n        vector<int>
![image.png](https://assets.leetcode.com/users/images/10db0793-bf3c-4a97-b062-d4471e1dfcd6_1721723791.9509678.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int nthUglyNumber(int n) {\n        int un1 = 1;\n        int un2 = 1;\n        int un3 = 1;\n        vector<int> arr(n + 1);\n        arr[1] = 1;\n        for (int i = 2; i <= n; i++) {\n            int a = arr[un1] * 2;\n            int b = arr[un2] * 3;\n            int c = arr[un3] * 5;\n\n            int findnextugly = min({a, b, c});\n            arr[i] = findnextugly;\n            if (findnextugly == a)\n                un1++;\n            if (findnextugly == b)\n                un2++;\n            if (findnextugly == c)\n                un3++;\n        }\n        return arr[n];\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Python', 'C++', 'Java']