Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 683 Bytes

0279-perfect-squares.adoc

File metadata and controls

33 lines (23 loc) · 683 Bytes

279. Perfect Squares

当前节点最小的值为当前值减去一个平方对应数字的值再加一,再众多选项中的最小值。

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …​) which sum to n.

Example 1:

Input: n = 12
Output: 3
Explanation: 12 = 4 + 4 + 4.

Example 2:

Input: n = 13
Output: 2
Explanation: 13 = 4 + 9.
link:{sourcedir}/_0279_PerfectSquares.java[role=include]