C++ heap solution
\n#define ll long long int\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        ll top, i=0;\n        vector<int> arr(n
```\n#define ll long long int\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        ll top, i=0;\n        vector<int> arr(n, -1);\n        priority_queue<ll, vector<ll>, greater<ll>> pq={};\n        pq.push(1);\n        while(!pq.empty() && arr[n-1]==-1){\n            top=pq.top();\n            arr[i++]=top;\n            pq.pop();\n            for(auto elt:primes)\n                pq.push(top*elt);\n            while(!pq.empty() && top==pq.top())\n                pq.pop();\n        }\n        return arr[n-1];\n    }\n};\n```
[]