This is the what I came up with. using binary search with bunch of testings. Can you guys please comment on my code?

```
public int searchInsert(int[] A, int target) {
if (A.length == 0 || A[0] >= target)
return 0;
if (target > A[A.length-1])
return A.length;
int start = 0;
int end = A.length-1;
while (start < end) {
int mid = (start + end) / 2;
if (A[mid] == target)
return mid;
if (A[mid] < target && target <= A[mid+1])
return mid+1;
if (A[mid] > target)
end = mid;
else
start = mid + 1;
}
return 0;
}
```