Very Simple and Clean JAVA code
public int nthSuperUglyNumber(int n, int[] primes) {\n        int[] a = new int[n];\n        int k = primes.length;\n        int[] p = new int[k];\n        a[0]
    public int nthSuperUglyNumber(int n, int[] primes) {\n        int[] a = new int[n];\n        int k = primes.length;\n        int[] p = new int[k];\n        a[0] = 1;\n        for (int i = 1; i < n; i++) {\n            for (int j = 0; j < k; j++) {\n                while (primes[j] * a[p[j]] <= a[i - 1]) {\n                    p[j]++;\n                }\n            }\n            a[i] = Integer.MAX_VALUE;\n            for (int j = 0; j < k; j++) {\n                a[i] = Math.min(a[i], primes[j] * a[p[j]]);\n            }\n        }\n        return a[n - 1];\n    }
[]