My Python Heap Solution 556ms
import heapq\n    \n    class Solution(object):\n        def nthSuperUglyNumber(self, n, primes):\n            if not n or n < 1 or not primes:\n               
    import heapq\n    \n    class Solution(object):\n        def nthSuperUglyNumber(self, n, primes):\n            if not n or n < 1 or not primes:\n                return 0\n            res = [1]\n            heap = [(prime, 0, prime) for prime in primes]\n            heapq.heapify(heap)\n            for i in xrange(1, n):\n                val, idx, prime = heapq.heappop(heap)\n                res.append(val)\n                heapq.heappush(heap, (res[idx + 1] * prime, idx + 1, prime))\n                while heap[0][0] <= val:\n                    _, idx, prime = heapq.heappop(heap)\n                    heapq.heappush(heap, (res[idx + 1] * prime, idx + 1, prime))\n            return res[-1]
['Python']