python priority queue
The idea is to use a priority queue to keep track of the smallest ugly number. \n2. For the next ugly generator, the priority queue saves the first index of the
1. The idea is to use a priority queue to keep track of the ```smallest``` ugly number. \n2. For the next ugly generator, the priority queue saves the first ```index``` of the ugly number that haven\'t been multiplied by the ```prime```. \n\n```\nimport heapq\nclass Solution(object):\n    def nthSuperUglyNumber(self, n, primes):\n        """\n        :type n: int\n        :type primes: List[int]\n        :rtype: int\n        """\n        if not primes:\n            return 0\n        \n        ugly_number = [1 for _ in xrange(n)]\n        hq = [(primes[i], 1, primes[i]) for i in xrange(len(primes))]\n        heapq.heapify(hq)\n        \n        for i in xrange(1, n):\n            ugly_number[i] = hq[0][0]\n            while ugly_number[i] == hq[0][0]:\n                value, idx, prime = heapq.heappop(hq)\n                heapq.heappush(hq, (ugly_number[idx] * prime, idx + 1, prime))\n        \n        return ugly_number[-1]        \n        \n```
[]