add some comments even though it is pretty straight forward.

public class Solution {

public int searchInsert(int[] A, int target) {

if (A == null || A.length == 0) {

return 0;

}

int start = 0, end = A.length - 1;

while (start <= end) {

int mid = (start + end) / 2;

```
// if target is found, simply return its index
if (A[mid] == target) {
return mid;
}
if (A[mid] < target) {
start = mid + 1;
} else {
end = mid - 1;
}
}
// when start > end, which means target is not in array,
// we should return the index target should be in.
// Since we know the target must be in {A[end], target, A[start]},
// the index value equals start.
return start;
}
```

}