Python 97%, 100%, with explanation
The overall idea is to build the super ugly number sequence in order until we have n values.\nTo find the next value in the sequence, we need to find the min pr
The overall idea is to build the super ugly number sequence in order until we have n values.\nTo find the next value in the sequence, we need to find the min product of a number in the\ncurrent sequence and a prime in the list. In order to avoid redundant computations, for each prime\nwe use an index to tell us the next value in the current sequence for which we should obtain a product.\n\n```\nfrom heapq import heapify, heappop, heappush\nclass Solution(object):\n    def nthSuperUglyNumber(self, n, primes):\n        super_ugly_numbers = []\n        heap = [1]\n        heapify(heap)\n        indexes = {1: [[0, p] for p in primes]}\n        while len(super_ugly_numbers) < n:\n            super_ugly_numbers.append(heappop(heap))\n            for tup in indexes[super_ugly_numbers[-1]]:\n                new_ugly = super_ugly_numbers[tup[0]] * tup[1]    \n                if new_ugly in indexes:\n                    indexes[new_ugly].append([tup[0] + 1, tup[1]])\n                else:\n                    indexes[new_ugly] = [[tup[0] + 1, tup[1]]]\n                    heappush(heap, new_ugly)\n            del indexes[super_ugly_numbers[-1]]\n        return super_ugly_numbers[-1]\n```\n\n\n    Example\n    Initialization:\n          super_ugly_numbers = []\n          heap = [1]\n          indexes = {\n              1: [[0,2], [0,7], [0,13], [0,19]]\n          }\n    Iteration 1 :\n          super_ugly_numbers = [1]\n          heap = [2, 7, 13, 19]\n          indexes = {\n              2: [[1,2]],\n              7: [[1,7]],\n              13: [[1,13],\n              19: [1,19]]\n          }\n    Iteration 2:\n          super_ugly_numbers = [1,2]\n          heap = [4, 7, 13, 19]\n          indexes = {\n              4: [[2,2]],\n              7: [[1,7]],\n              13: [[1,13],\n              19: [1,19]]\n          }\n    Iteration 3:\n          super_ugly_numbers = [1,2,4]\n          heap = [8, 7, 13, 19]\n          indexes = {\n              8: [[3,2]],\n              7: [[1,7]],\n              13: [[1,13],\n              19: [1,19]]\n          }\n    Iteration 4:\n          super_ugly_numbers = [1,2,4,7]\n          heap = [8, 13, 14, 19]\n          indexes = {\n              8: [[3,2]],\n              14: [[2,7]],\n              13: [[1,13],\n              19: [1,19]]\n          }...
[]