112ms C++ solution with explanation
class Solution {\n    public:\n        int nthSuperUglyNumber(int n, vector<int>& primes) {\n            vector<int> superUglyNumbers;\n            superUglyNum
    class Solution {\n    public:\n        int nthSuperUglyNumber(int n, vector<int>& primes) {\n            vector<int> superUglyNumbers;\n            superUglyNumbers.push_back(1);  // first super ugly number\n            int numPrimes = primes.size();\n            vector<int> idxs(numPrimes, 0);\n            // add super ugly number up to nth \n            while(superUglyNumbers.size() < n)\n            {\n                int nextSuperUglyNumber = superUglyNumbers[idxs[0]]*primes[0];   // next super ugly number\n                for(int i = 0; i < numPrimes; i++)\n                {\n                    nextSuperUglyNumber = min(nextSuperUglyNumber, superUglyNumbers[idxs[i]]*primes[i]);\n                }\n                for(int i = 0; i < numPrimes; i++)\n                {\n                    if(nextSuperUglyNumber == superUglyNumbers[idxs[i]]*primes[i])\n                    {\n                        idxs[i]++;\n                    }\n                }\n                superUglyNumbers.push_back(nextSuperUglyNumber);\n            }\n            \n            return superUglyNumbers[n-1];\n        }\n    };
['C++']