Newton's method can be helpful here, for an easy and fastest solution


#1

class Solution:
# @param A : integer
# @return an integer
def sqrt(self, A):
p = int(A/2)
if(A==0):
return 0
if(A==1):
return 1
while(p*p>A):

        sqrt_of_number = int((p+(A/p))/2)
        p=sqrt_of_number
        
    return p.

#2

Check the ans for A=3