43. Perfect Squares

Given an integer n. Return the least number of perfect square numbers that sum to n.
Example 1
Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4; it cannot be represented with fewer than three squares.
Example 2
Input: n = 13
Output: 2
Explanation: 13 = 9 + 4, so two squares are enough.
arraysmediumqueue
JavaScript
Loading...
Line 1, Char 1