Time complexity for this solution is O ( lgn ), you will also find the condition to move left or right here.
see from question I can conclude that array must be of odd length...right
because every element but one is repeated twice, arr[] = 1,1,2,2,3,4,4 --> length = 7
lets start binary search with middle_element_index = floor( 7 / 2 ) = 3
arr[ 3 ] = 2 1,1,2,2,3,4,4
now compare this element with next and previous index element
if arr[3] matched with previous element: 1,1,2,2,3,4,4
your single element must be on right side of this middle
if arr[3] matched with next element:
( for this condition to satisfy your array must have been like this 1,2,2,3,3,4,4 )
your single element must be on left side of this middle
else you found that single (bachelor) element who was disturbing other couples :
find appropriate side to move, find next middle on that side and repeat procedure
until you either reach end, or both next and previous element different, in that case you found single element