Java -- DP
```\nclass Solution {\n    public int nthSuperUglyNumber(int n, int[] primes) {\n        \n        if (primes.length == 0 || n == 0)\n            return 0;\n   
```\nclass Solution {\n    public int nthSuperUglyNumber(int n, int[] primes) {\n        \n        if (primes.length == 0 || n == 0)\n            return 0;\n        \n        int[] uglies = new int[n];\n        int[] counters = new int[primes.length];\n        \n        uglies[0] = 1;\n        \n        for (int i = 1; i < n; i++) {\n            int nextMin = Integer.MAX_VALUE;\n            \n            // loop through the primes and find the next smallest one\n            for (int j = 0; j < primes.length; j++)\n                // we found a smaller value -- also don\'t add duplicates\n                if (nextMin > uglies[counters[j]] * primes[j])\n                    nextMin = uglies[counters[j]] * primes[j];\n            \n            uglies[i] = nextMin;\n            \n            // advance all matching counters to avoid duplicates\n            for (int j = 0; j < primes.length; j++)\n                if (uglies[counters[j]] * primes[j] == nextMin)\n                    counters[j]++;\n        }\n        \n        return uglies[n - 1];\n    }\n}
['Dynamic Programming', 'Java']