From 3a16650abe53b59bb9ab99c931993ef1f253d22c Mon Sep 17 00:00:00 2001 From: ZerenZhang2022 <118794589+ZerenZhang2022@users.noreply.github.com> Date: Mon, 6 Mar 2023 01:49:19 -0500 Subject: [PATCH 1/2] =?UTF-8?q?Update=200202.=E5=BF=AB=E4=B9=90=E6=95=B0.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit python的另一种写法 - 通过字符串来计算各位平方和 --- problems/0202.快乐数.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/problems/0202.快乐数.md b/problems/0202.快乐数.md index 1a7d53a3..2687574f 100644 --- a/problems/0202.快乐数.md +++ b/problems/0202.快乐数.md @@ -132,6 +132,19 @@ class Solution: else: record.add(n) +# python的另一种写法 - 通过字符串来计算各位平方和 +class Solution: + def isHappy(self, n: int) -> bool: + record = [] + while n not in record: + record.append(n) + newn = 0 + nn = str(n) + for i in nn: + newn+=int(i)**2 + if newn==1: return True + n = newn + return False ``` Go: From 202013fd817e303e14d5f43a324b55b9c9810ead Mon Sep 17 00:00:00 2001 From: Jeremy Feng <44312563+jeremy-feng@users.noreply.github.com> Date: Tue, 7 Mar 2023 17:46:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Update=200070.=E7=88=AC=E6=A5=BC=E6=A2=AF.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改错别字 --- problems/0070.爬楼梯.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0070.爬楼梯.md b/problems/0070.爬楼梯.md index 14aeef01..d4a7881d 100644 --- a/problems/0070.爬楼梯.md +++ b/problems/0070.爬楼梯.md @@ -72,7 +72,7 @@ dp[i]: 爬到第i层楼梯,有dp[i]种方法 3. dp数组如何初始化 -在回顾一下dp[i]的定义:爬到第i层楼梯,有dp[i]中方法。 +再回顾一下dp[i]的定义:爬到第i层楼梯,有dp[i]中方法。 那么i为0,dp[i]应该是多少呢,这个可以有很多解释,但基本都是直接奔着答案去解释的。