Extended Concept of Ugly Number II || C++
\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        long long dp[n]; //To Store the answer\n        long long m = pri
```\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        long long dp[n]; //To Store the answer\n        long long m = primes.size(); \n        vector<long long> index(m,0); //To store the index of each prime number and track it\'s increment\n        vector<long long> nxt(m,0); //To track next min possible number using jth prime number\n        long long next=1;\n        dp[0]=1;\n        for(int i=0;i<m;i++)\n            nxt[i] = primes[i]; //Storing all prime number in an array Basically indexing them\n        long long inf=1e18;\n        for(int i=1;i<n;i++)\n        {\n            next=inf;\n            for(int j=0;j<m;j++)\n                next = min(nxt[j],next);//Find next possible ans\n            dp[i]=next;//Assign it\n            for(int j=0;j<m;j++)\n            {\n                if(next%nxt[j]==0) //If that next number multiple of particular prime number then assign its next multiple to the array tracking  their record\n                {\n                    index[j]++; //Just by incrementing index to get next multiple of the prime\n                    nxt[j] = dp[index[j]]*primes[j];\n                }\n            }\n        }\n        return dp[n-1];//Return ans\n    }\n};\n```
[]