Find the element that appears once in an array where every other element appears twice | singleelement function ; Driver code
def singleelement ( arr , n ) : NEW_LINE INDENT low = 0 NEW_LINE high = n - 2 NEW_LINE mid = 0 NEW_LINE while ( low <= high ) : NEW_LINE INDENT mid = ( low + high ) // 2 NEW_LINE if ( arr [ mid ] == arr [ mid ^ 1 ] ) : NEW_LINE INDENT low = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT high = mid - 1 NEW_LINE DEDENT DEDENT return arr [ low ] NEW_LINE DEDENT arr = [ 2 , 3 , 5 , 4 , 5 , 3 , 4 ] NEW_LINE size = len ( arr ) NEW_LINE arr . sort ( ) NEW_LINE print ( singleelement ( arr , size ) ) NEW_LINE