Just two 'for'-loops and an 'if'
Intuition\nThere\'s not much to this problem. For each prime, we\'ll keep track of an index into our computed list of \'uglies\' and also the next multiple for 
# Intuition\nThere\'s not much to this problem. For each prime, we\'ll keep track of an index into our computed list of \'uglies\' and also the next multiple for that prime. At each step of the algorithm, the next ugly number is given by min(next). The code below doesn\'t use any special data structures, nor does it perform any wasted multiplications (some other peoples\' solutions do).\n\n# Complexity\n- Time complexity:\nO(n * len(primes))\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution:\n    def nthSuperUglyNumber(self, n: int, primes: List[int]) -> int:\n        uglies = [1]\n        np = len(primes)\n        indices = [0] * np\n        next = primes.copy()\n\n        for i in range(1, n):\n            uglies.append(ugly := min(next))\n\n            for k in range(np):\n                if ugly == next[k]:\n                    indices[k] += 1\n                    next[k] = primes[k] * uglies[indices[k]]\n\n        return uglies[n - 1]\n\n```
['Python3']