c++ priority queue nlogk
\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int>nums(n);\n        vector<int>indices(primes.size()); // index of the prime number
```\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int>nums(n);\n        vector<int>indices(primes.size()); // index of the prime number inside nums array\n        nums[0] = 1;\n\t\t// first item is value of ugly number, second item is identity of the prime\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>pq;\n        for(int i=0; i<primes.size(); ++i)  pq.emplace(primes[i], i);\n        for(int i=1; i<n; ){\n            auto [val, id] = pq.top();\n            pq.pop();\n            if(val != nums[i-1])    nums[i++] = val; // avoid duplicate\n            if(INT_MAX/primes[id]>nums[indices[id]+1]) // prevent overflow\n                pq.emplace(nums[++indices[id]] * primes[id], id);\n        }\n        return nums.back();\n    }\n```
['C', 'Heap (Priority Queue)']