Skip to content

Latest commit

 

History

History
17 lines (16 loc) · 347 Bytes

202.md

File metadata and controls

17 lines (16 loc) · 347 Bytes
  • 32ms
  • 68%
class Solution:
    def isHappy(self, n: int) -> bool:
        visited = set()
        while True:
            if n in visited: return False
            if n==1: return True
            visited.add(n)
            tmp = 0
            while n:
                tmp += (n%10)**2
                n //= 10
            n = tmp