Perfect Squares

Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer.

Constraints

  • 1 <= n <= 10^4
Auto-saved · 2 lines
class Solution:
def leastNumOfPerfectSquares(self, n: int) -> int:
Console

Click Run to execute sample tests.