C++ | Heap with triplet
\n#define ll long long\nclass Solution {\n    struct triplet{\n        ll primeNumber, index, element;\n        triplet(ll pn, ll idx, ll e){\n            prime
```\n#define ll long long\nclass Solution {\n    struct triplet{\n        ll primeNumber, index, element;\n        triplet(ll pn, ll idx, ll e){\n            primeNumber = pn;\n            index = idx;\n            element = e;\n        }\n    };\n    \n    struct compare{\n        bool operator()(triplet &t1, triplet &t2){\n            return t1.element > t2.element;      \n        }\n    };\n    \npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int>v(1,1);\n        priority_queue<triplet, vector<triplet>, compare>pq;\n        \n        for(auto k:primes){\n            pq.push({k, 0, k});\n        }\n\n        while(v.size() < n){\n            triplet top = pq.top();\n            pq.pop();\n            if(top.element > v.back()){\n                v.push_back(top.element);\n            }\n            pq.push({top.primeNumber, top.index+1, (top.primeNumber * v[(top.index + 1)])});\n        }\n        \n        return v.back();\n    }\n};\n```
[]