C++ || Priority Queue Solution || O(NlogK)
```\nclass Solution {\npublic:\n    // Time: O(NlogK)\n    #define ll long long\n    #define vv  vector\n    int nthSuperUglyNumber(int n, vector& primes) \n   
```\nclass Solution {\npublic:\n    // Time: O(NlogK)\n    #define ll long long\n    #define vv  vector<long long>\n    int nthSuperUglyNumber(int n, vector<int>& primes) \n    {\n        priority_queue<vv,vector<vv>,greater<vv>> pq;\n        vector<ll> dp(n, 0);\n        dp[0]=1;\n\n        int k = primes.size();\n        for(int i=0; i<k; i++)\n        {\n            //values, pointer of prime no, prime_no\n            pq.push({primes[i], 1, primes[i]});//sort acc to values\n        }        \n        int cnt=1;\n        while(!pq.empty() and cnt < n)\n        {\n            vector<ll> top = pq.top();\n            pq.pop();\n            int pointer = top[1];\n            int prime_no = top[2];\n            int value = top[0];\n    \n//we will only update our ans when it is not equal to the previous val in our dp vector as we don\'t want repeating values\n            if(dp[cnt-1] != value)\n            {\n                dp[cnt] = value;\n                top[0] = dp[pointer]*prime_no;\n                pointer++;//we will increment the pointer \n    \n                pq.push({top[0],pointer,prime_no});\n                cnt++;\n            }\n\n//we will only not update our dp[idx] but we will insert new pair for this case\n            else if(dp[cnt-1] == value)\n            {\n                //we will not update our cnt as we are not updating our dp idx\n                top[0] = dp[pointer]*prime_no;\n                pointer++;\n    \n                pq.push({top[0],pointer,prime_no});                \n            }\n        }\n        return dp[n-1];\n    }\n};
['Heap (Priority Queue)', 'C++']