Return the fewest perfect squares (1, 4, 9, 16, ...) that add up to n.
For n = 12 the answer is 3 (4 + 4 + 4); for n = 13 it is 2 (4 + 9).
The starter code is a plain recursion. It is correct but too slow for large n.
Example 1
Input:
num_squares(12)
Output:
3
Example 2
Input:
num_squares(13)
Output:
2
0 <= n <= 12000No results yet
Run your code to check it against the examples, or submit to run every test.