✅
<<< 264. Ugly Number II\n\nhttps://leetcode.com/problems/ugly-number-ii/solutions/3709599/easy-to-understand/\n\n# Code\n\nclass Solution {\n    public int nthS
**<<< 264. Ugly Number II**\n\nhttps://leetcode.com/problems/ugly-number-ii/solutions/3709599/easy-to-understand/\n\n# Code\n```\nclass Solution {\n    public int nthSuperUglyNumber(int n, int[] primes) {\n        long[] dp=new long[n];\n        dp[0]=1;\n        int[] indexArr=new int[primes.length];\n        for(int i=1; i<n; i++){\n            long minValue=Long.MAX_VALUE;\n            for(int j=0; j<primes.length; j++){\n                minValue=Math.min(minValue,dp[indexArr[j]]*primes[j]);\n            }\n            dp[i]=minValue;\n            for(int j=0; j<primes.length; j++){\n                if(dp[i]==dp[indexArr[j]]*primes[j]){\n                    indexArr[j]++;\n                }\n            }\n        }\n        return (int)dp[n-1];\n    }\n}\n```
['Dynamic Programming', 'Java']