202Happy Number

xiaoxiao2021-02-28  53

class Solution(object):     def isHappy(self, n):         """         :type n: int         :rtype: bool         """         stop={1}         while n not in stop:             stop.add(n)             n=sum(int(x)**2 for x in str(n))         return n==1         
转载请注明原文地址: https://www.6miu.com/read-54402.html

最新回复(0)