Skip to content

Commit d9c998f

Browse files
authored
Create 202.py
1 parent 98469a6 commit d9c998f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

101-500/202.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution(object):
2+
def isHappy(self, n, prev=[]):
3+
nums = sum([int(x)**2 for x in list(str(n))])
4+
if nums in prev:
5+
return False
6+
return self.isHappy(nums, prev+[nums]) if nums != 1 else True
7+
"""
8+
:type n: int
9+
:rtype: bool
10+
"""
11+

0 commit comments

Comments
 (0)