[C++] Solution using DP
\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> dp(n,0);\n        dp[0] = 1;\n        unordered_map<i
```\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> dp(n,0);\n        dp[0] = 1;\n        unordered_map<int,int> pointer;\n        \n        for(int i=0;i<primes.size();++i)\n            pointer[primes[i]] = 0;\n        \n        for(int i=1;i<n;++i)\n        {\n            int mn = INT_MAX;\n            for(int j=0;j<primes.size();++j)\n            {\n                mn = min(mn,primes[j] * dp[pointer[primes[j]]]);\n            }\n            dp[i] = mn;\n            for(int j=0;j<primes.size();++j)\n            {\n                if(dp[i] % primes[j] == 0)\n                    pointer[primes[j]]++;\n            }\n        }\n        return dp[n-1];\n    }\n};\n```
['Dynamic Programming', 'C++']