JAVA || Clean & Concise & Optimal Code || Dynamic Programming Approach || 90% Faster Solution
\nclass Solution {\n    public int nthSuperUglyNumber(int n, int[] primes) {\n        \n        int[] count = new int[primes.length];\n        int[] dp = new in
```\nclass Solution {\n    public int nthSuperUglyNumber(int n, int[] primes) {\n        \n        int[] count = new int[primes.length];\n        int[] dp = new int[n];\n        dp[0] = 1;\n        \n        for (int i = 1; i < n; i++) {\n            int currUglyNumber = Integer.MAX_VALUE;\n            \n            for (int j = 0; j < primes.length; j++) {\n                currUglyNumber = Math.min (currUglyNumber, dp[count[j]] * primes[j]);\n            }\n            \n            for (int j = 0; j < count.length; j++) {\n                if (currUglyNumber == dp[count[j]] * primes[j]) {\n                    ++count[j];\n                }\n            }\n            \n            dp[i] = currUglyNumber;\n        }\n        \n        return dp[n - 1];\n    }\n}\n```\n\nPlease help to **UPVOTE** if this post is useful for you.\nIf you have any questions, feel free to comment below.\n\n**LOVE CODING :)\nHAPPY CODING :)\nHAPPY LEARNING :)**
['Dynamic Programming', 'Java']