Given an integer , return the least number of perfect square numbers that sum to . For example, , so the answer is .
This problem uses sequences in a different way: the sequence of perfect squares forms the building blocks.
You need dynamic programming here, but understanding that you're working with the sequence for helps you structure the solution.