# Sqrt(x) (Leetcode 69)

Problem Link: <https://leetcode.com/problems/sqrtx/>

```python
class Solution:
    def mySqrt(self, x: int) -> int:

        def bsearch(l,r):
            mid=l+(r-l)//2
            while(l<=r):
                if(mid*mid==x):
                    self.res=mid
                    return mid
                elif(mid*mid<x):
                    self.res=mid
                    return bsearch(mid+1,r)
                else:
                    return bsearch(l,mid-1)
            return -1
            
        self.res=0
        bsearch(1,x)
        return self.res
```
