My easy understanding Java solution, with PriorityQueue
\npublic int nthSuperUglyNumber(int n, int[] primes) {\n        if (n == 1) {\n            return 1;\n        }\n        PriorityQueue<Integer> pq = new Priorit
```\npublic int nthSuperUglyNumber(int n, int[] primes) {\n        if (n == 1) {\n            return 1;\n        }\n        PriorityQueue<Integer> pq = new PriorityQueue<>();\n        for (int x : primes) {\n            pq.offer(x);\n        }\n        for (int i=0; i<n-2; ++i) {\n            int cur = pq.poll();\n            for (int x : primes) {  //each one pop out should multiply the array\n                long mult = (long)cur * (long)x;\n                if (mult < Integer.MAX_VALUE) {\n                    pq.offer((int)mult);\n                }\n            }\n            while (pq.peek() == cur) {  // It is sorted, so if duplicate, only happen at root, poll it\n                pq.poll();\n            }\n        }\n        return pq.poll();\n    }\n```
[]