# Leetcode 279 - Perfect squares

`Note`

- DP question.
- Use math to create a
`nums`

array whose length is`Math.ceil(sqrt(n))`

. - The deduction is
`dp[j] = Math.min(dp[j], dp[j - nums[i]] + 1)`

. - Similar to coin change question, we need to initialize dp elements as
`Infinity`

. - Initialize DP[0] = 0 after doing a experiment.

Given an integer n, return the least number of perfect square numbers that sum to n.

A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.

**Example**

1 | Input: n = 12 |

1 | /** |