C++ Simple Solution
\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int>ugly(n,0);\n        ugly[0]=1;\n        sort(primes.be
```\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int>ugly(n,0);\n        ugly[0]=1;\n        sort(primes.begin(),primes.end());\n        vector<int>ptr(primes.size(),0);\n        for(int i=1;i<n;i++){\n            int mn=INT_MAX;\n            for(int j=0;j<primes.size();j++)\n                mn=min(mn,primes[j]*ugly[ptr[j]]);\n            ugly[i]=mn;\n            for(int j=0;j<primes.size();j++){\n                if(mn%primes[j]==0)\n                    ptr[j]++;\n            }\n        }\n        return ugly[n-1];\n    }\n};\n```
[]