Skip to content

Instantly share code, notes, and snippets.

@vamsitallapudi
Created April 3, 2020 06:00
Show Gist options
  • Save vamsitallapudi/0eec6d7bf8d5f1610b16707cf60e4c95 to your computer and use it in GitHub Desktop.
Save vamsitallapudi/0eec6d7bf8d5f1610b16707cf60e4c95 to your computer and use it in GitHub Desktop.
class Solution:
def isHappy(self, n: int) -> bool:
result = False
visited = set()
while not result and n not in visited:
visited.add(n)
p = [int(_) for _ in str(n)]
n = sum(list(map(lambda a: a ** 2, p)))
if n == 1:
result = True
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment