Python, DP, O(n), with explanation.
\nclass Solution(object):\n    def nthUglyNumber(self, n):\n        """\n        DP approach.\n        The idea is to add the numbers to the uglyNumbers list on
```\nclass Solution(object):\n    def nthUglyNumber(self, n):\n        """\n        DP approach.\n        The idea is to add the numbers to the uglyNumbers list one-by-one by multiplying 2 \n        or 3 or 5. While adding the values, we must make sure that a value lesser than\n        previously added won\'t be divisible by the other 2 primes. Hence, increment the\n        pointers such that next minimum value can be added to the list.\n        """\n        uglyNumbers = [1]\n        p2 = p3 = p5 = 0\n        \n        while len(uglyNumbers) < n:\n            #If a value lesser than latest was already added, try finding next least value.\n            while uglyNumbers[p2]*2 <= uglyNumbers[-1]:\n                p2 += 1\n            \n            while uglyNumbers[p3]*3 <= uglyNumbers[-1]:\n                p3 += 1\n            \n            while uglyNumbers[p5]*5 <= uglyNumbers[-1]:\n                p5 += 1\n            \n            nextVal = min(uglyNumbers[p2]*2, uglyNumbers[p3]*3, uglyNumbers[p5]*5)\n            uglyNumbers.append(nextVal)\n        \n        return uglyNumbers[-1]\n        \n```
[]