TC - O(n*k)  ||  SC  - O(n+k)
/\ntc - O(nk) ; k = primes.length\nsc - O(n + k)\n/\n\n#define ll long long int\n\nclass Solution {\n    \npublic:\n    ll minFunc(ll a, ll b){\n        if(a < 
/*\ntc - O(nk) ; k = primes.length\nsc - O(n + k)\n*/\n```\n#define ll long long int\n\nclass Solution {\n    \npublic:\n    ll minFunc(ll a, ll b){\n        if(a < b) return a;\n        return b;\n    }\n    \npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        \n        vector<ll> pointers(primes.size(), 0);\n        \n        vector<ll> dp(n, 0);\n        dp[0] = 1;\n        \n        for(int i = 1; i < n; i++){\n            \n            int mini = INT_MAX;\n            \n            for(int i = 0; i < pointers.size(); i++){\n                mini =  minFunc(mini, dp[pointers[i]] * primes[i]);\n            }\n            \n            for(int i = 0; i < pointers.size(); i++){\n                if(mini == dp[pointers[i]]*primes[i]){\n                   pointers[i]++; \n                }\n            }\n            \n            dp[i] = mini;\n        }\n        \n        int ans = dp[n-1];\n        return ans;\n        \n    }\n};\n```
['C++']