Prompt: Given an integer n, return the least number of perfect squares that sum up to n.

Note: A perfect square is an integer that is a square of an integer. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.

Example:

Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4.
Input: n = 13
Output: 2
Explanation: 13 = 4 + 9.

Solution: We can solve this with bottom up tabulation. The base case of the DP problem is when i = 1. The target state of the DP problem is i = n. For each state, if i is a perfect square, the number of perfect squares that sum up to i is 1. However, if i is not a perfect square, we can loop through all previous perfect squares, j, and calculate the number of perfect squares as the minimum of 1 + dp[i-j].