Find the element that appears once in an array where every other element appears twice | function to find the once appearing element in array ; Do XOR of all elements and return ; Driver code
def findSingle ( ar , n ) : NEW_LINE INDENT res = ar [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT res = res ^ ar [ i ] NEW_LINE DEDENT return res NEW_LINE DEDENT ar = [ 2 , 3 , 5 , 4 , 5 , 3 , 4 ] NEW_LINE print " Element ▁ occurring ▁ once ▁ is " , findSingle ( ar , len ( ar ) ) NEW_LINE