# Binary Search (Leetcode 704)

Problem Link: <https://leetcode.com/problems/binary-search/>

```python
class Solution:
    def search(self, nums: List[int], target: int) -> int:
        
        def bsearch(nums,target,i,j):
            
            mid=(i+j)//2
            while(i<=j):
                if(nums[mid]==target):
                    return mid
                elif(nums[mid]<target):
                    return bsearch(nums,target,mid+1,j)
                elif(nums[mid]>target):
                    return bsearch(nums,target,i,mid-1)
            
            return -1
                           
        nums.sort()
        n=len(nums)
        i=0
        j=n-1
        return bsearch(nums,target,i,j)
```
