my python solution

  • 1
    class Solution(object):
        def isHappy(self, n):
            :type n: int
            :rtype: bool
            col = set()
            while(n not in col):
                n = sum(int(i)**2 for i in str(n))
            return n==1

  • 0

    interesting. I wonder , what will be the algorithmic complexity of this solution.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.