```
class Solution {
public:
int search(int A[], int n, int target) {
if(n == 0){
return -1;
}
return __search(A , 0 , n-1 , target);
}
private:
int __search(int A[] , int start , int end , int target){
if(start > end)
return -1;
int mid = (start+end)/2;
if(target == A[mid])
return mid;
else{
int x = __search(A , start , mid-1 , target);
if(x < 0){
return __search(A , mid+1 , end , target);
}else{
return x;
}
}
}
};
```

My algo is searching in both sides , the best case is O(logn) .