It can be logn. First look for num - 1, get n1, then look for num + 1, get n2.
Here comes a trick.
Here is the binary search we should use,
while(start <= end){
// do what normal binary search should do.
}
//if num - 1 or num + 1 is not in the array.
return start - 1;