Happy Number LeetCode solution in Python

1
class Solution(object):
2
def isHappy(self, n):
3
hset = set()
4
while n != 1:
5
if n in hset:
6
return False
7
hset.add(n)
8
n = sum([int(i) ** 2 for i in str(n)])
9
else:
10
return True

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0