Medium · Dynamic Programming
Perfect Squares
Given an integer n, return the least number of perfect squares (1, 4, 9, 16 and so on, each usable any number of times) that sum to n.
Examples
Example 1
n = 12Output: 3 squares
Example 2
n = 7Output: 4 squares
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.