Leetcode Ugly Number

The Problem Ugly Number II and Super Ugly Number , because I didn't write the Ugly Number I, so, I don't have any idea at first. According to the related tag, I have an idea of Priority Queue and Hash Table, but I still want to know how to deal it with Dynamic Programming.

For Dynamic Programming problem, I think the most important details is:

  1. Design an Array(sometimes) to save the Optimal solution, I mean the Optimal solution of subproblem is very important. A good design cloud make problem must easier, for example, in problem Best Time to Buy and Sell Stock IV
  2. In this problem, we can easily design the DP array, but State transition equation is difficult in this problem.