This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Description
For the binary search solution (), the binary search algorithm is not working finding the first and the last numbers.
I propose this approach.
`public static int findTarget(int[] arr, int target) {
if (arr.length == 0) return -1;
int start = 0, end = arr.length;
while (start<=end) {
int mid = (start+end)/2;
if(arr[mid]==target)
return mid;
else if(arr[mid]<target){
start=mid+1;
}
else {
end=mid-1;
}
}
return -1;
}`