Java 31ms O(nlgk) Solution with Heap
Similar to Ugly Number II, use min-heap to manage numbers.\n\n    public int nthSuperUglyNumber(int n, int[] primes){\n        int[] index = new int[1000];\n   
Similar to Ugly Number II, use min-heap to manage numbers.\n\n    public int nthSuperUglyNumber(int n, int[] primes){\n        int[] index = new int[1000];\n        int[] res = new int[n];\n        int[] heap = new int[primes.length];\n        for(int i = 0;i<primes.length; i++)heap[i] = primes[i];\n        res[0] = 1;\n        for(int i = 1; i<n;)\n        {\n            if(res[i-1] != heap[0]){        \t\n            \tres[i] = heap[0];\n            \tSystem.out.print(res[i]+" ");\n            \ti++;\n            }\n            updateHeap(heap,primes,index,res);\n        }\n        return res[n-1];\n    }\n    public void heapify(int[] heap, int[] primes, int i){\n        int index = i;\n        int left = 2*i+1; int right = left+1;\n        if(heap.length>left && heap[i] > heap[left]) index = left;\n        if(heap.length>right && heap[index] > heap[right]) index = right;\n        if(i!=index){\n            int temp = heap[i];\n            heap[i] = heap[index];\n            heap[index] = temp;\n            int tempPri = primes[i];\n            primes[i] = primes[index];\n            primes[index] = tempPri;\n            heapify(heap,primes,index);\n        }\n    }\n    public void updateHeap(int[] heap, int[] primes, int[] index, int[] res)\n    {\n        index[primes[0]]++;\n        heap[0] = res[index[primes[0]]] * primes[0];\n        heapify(heap,primes,0);\n    }
['Java']