Binary search - finding first or last occurrence of a number