Fast Python solution based on solution for Ugly Number II
Just an extrapolation of @dietpepsi's solution for Ugly Number II\nhttps://leetcode.com/discuss/61443/ac-python-solution-o-n-time-o-n-space\n\n\n\n\n    class S
Just an extrapolation of @dietpepsi's solution for Ugly Number II\nhttps://leetcode.com/discuss/61443/ac-python-solution-o-n-time-o-n-space\n\n\n\n\n    class Solution(object):\n        def nthSuperUglyNumber(self, n, primes):\n            """\n            :type n: int\n            :type primes: List[int]\n            :rtype: int\n            """\n            ugly = [1] * n\n            i_list = [-1] * len(primes)\n            v_list = [1] * len(primes)\n            k = 0\n            while k < n:\n                x = min(v_list)\n                ugly[k] = x\n                for v in xrange(len(v_list)):\n                    if x == v_list[v]:\n                        i_list[v] += 1\n                        v_list[v] = ugly[i_list[v]] * primes[v]\n                k += 1\n            return ugly[k-1]
['Python']