Find the element that appears once | Method to find the element that occur only once ; one & arr [ i ] " gives the bits that  are there in both 'ones' and new  element from arr[]. We add these  bits to 'twos' using bitwise OR ; one & arr [ i ] " gives the bits that  are there in both 'ones' and new  element from arr[]. We add these  bits to 'twos' using bitwise OR ; The common bits are those bits which appear third time . So these bits should not be there in both ' ones ' and ' twos ' . common_bit_mask contains all these bits as 0 , so that the bits can be removed from ' ones ' and 'twos   ; Remove common bits ( the bits that appear third time ) from 'ones   ; Remove common bits ( the bits that appear third time ) from 'twos   ; driver code
def getSingle ( arr , n ) : NEW_LINE INDENT ones = 0 NEW_LINE twos = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT twos = twos | ( ones & arr [ i ] ) NEW_LINE ones = ones ^ arr [ i ] NEW_LINE common_bit_mask = ~ ( ones & twos ) NEW_LINE ones &= common_bit_mask NEW_LINE twos &= common_bit_mask NEW_LINE DEDENT return ones NEW_LINE DEDENT arr = [ 3 , 3 , 2 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE print ( " The ▁ element ▁ with ▁ single ▁ occurrence ▁ is ▁ " , getSingle ( arr , n ) ) NEW_LINE