Submitting failed but the answer is correct

  • 0

    I was wondering what might be wrong with my solution. It is returning as wrong answer for 10 but when I enter 10 for custom case it is returning true.

    class Solution(object):
        l =[]
        def isHappy(self, n):
            print self.l
            if n==1:
                return True
            elif n in self.l:
                return False
                su = 0
                    r = n%10
                    su+= r*r
                    n = n/10
                return self.isHappy(su)

Log in to reply

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