Clean Python Solution
python\nclass Solution(object):\n    def nthSuperUglyNumber(self, n, primes):\n        p = [0]*len(primes) #p[i] stores the index of ugly number in ans that not
```python\nclass Solution(object):\n    def nthSuperUglyNumber(self, n, primes):\n        p = [0]*len(primes) #p[i] stores the index of ugly number in ans that not yet times primes[i] yet\n        ans = [1]\n        h = []\n        \n        for i in xrange(len(primes)):\n            heapq.heappush(h, (primes[i]*ans[p[i]], i))\n            \n        for _ in xrange(n-1):\n            curr = h[0][0]\n            ans.append(curr)\n            \n            while h and h[0][0]==curr:\n                i = h[0][1]\n                heapq.heappop(h)\n                p[i] += 1\n                heapq.heappush(h, (primes[i]*ans[p[i]], i))\n        \n        return ans[-1]\n"""\nRelated Problems:\nUgly Number, Ugly Number II\nSuper Ugly Number\nFind K Pairs with Smallest Sums from two arrays\n\nFor more other topics similar problems, check out my GitHub.\nIt took me a lots of time to make the solution. Becuase I want to help others like me.\nPlease give me a star if you like it. Means a lot to me.\nhttps://github.com/wuduhren/leetcode-python\n"""\n```
[]