(Python) This code can't pass but I can't find where is wrong.


  • 0
    D

    By the way, it can pass in Idle, so I'm so confused.

    class Solution(object):
        def judgeSquareSum(self, c):
            """
            :type c: int
            :rtype: bool
            """
            flag=0
            exitFlag = False
            for a in range(int(c**(1/2))+2):
                for b in range(int(c**(1/2))+2):
                    if a*a+b*b==c:
                        flag=1
                        exitFlag = True
                        break
                if exitFlag:
                    break
            if flag==1:
                return True
            else:
                return False
                        ```

Log in to reply
 

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