210 - 279 完全平方数
Last updated
Was this helpful?
Last updated
Was this helpful?
给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n。你需要让组成和的完全平方数的个数最少。
示例 1:
输入: n = 12 输出: 3 解释: 12 = 4 + 4 + 4.
示例 2:
输入: n = 13 输出: 2 解释: 13 = 4 + 9.
开平方根,取地板,然后减掉这个数的平方。
Runtime: 6116 ms, faster than 12.00% of Python3 online submissions for Perfect Squares.
Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Perfect Squares.
Runtime: 56 ms, faster than 97.07% of Python3 online submissions for Perfect Squares.
Memory Usage: 12.5 MB, less than 100.00% of Python3 online submissions for Perfect Squares.