class Solution {
public:
int searchInsert(int A[], int n, int target) {
int low = 0,high = n  1;
while (low <= high){
int mid = (low + high) / 2;
if(A[mid]==target) return mid;
else if (A[mid] >target){
high = mid  1;
}
else{
low = mid + 1;
}
}
return low;
}
};
My 8ms accepted code.

Actually you can just iterate through the array, its still an 8ms solution...
class Solution { public: int searchInsert(int A[], int n, int target) { if(target <= A[0]) return 0; else if(target > A[n1]) return n; else { for(int i = 0; i < n1; i++) { if(target > A[i] && target <= A[i+1]) return i+1; } } } };
