class Solution(object):
def isHappyNumber(self, newSum, prevSumList):
if newSum == 1:
return True
if newSum in prevSumList:
return False
prevSumList.append(newSum)
newSum = sum([int(x)**2 for x in str(newSum)])
# print("Call - ",newSum)
res = self.isHappyNumber(newSum, prevSumList)
# print(newSum, res)
return res
def isHappy(self, n):
"""
:type n: int
:rtype: bool
"""
return self.isHappyNumber(n, [])