# Runtime: 28 ms, faster than 91.32% of Python3 online submissions for Happy Number.
# Memory Usage: 14 MB, less than 5.26% of Python3 online submissions for Happy Number.
class Solution:
def isHappy(self, n: int) -> bool:
nums = list(str(n))
total = 0
hashMap = {}
while total != 1:
for num in nums:
total += int(num) ** 2
if total == 1: return True
if hashMap.get(total, 0):
return False
else:
hashMap[total] = True
nums = list(str(total))
total = 0