human
Elements that occurred only once in the array | Function to find the elements that appeared only once in the array.
Sort the array.
Check for first element.
Check for all the elements if it is different its adjacent elements.
Check for the last element.
Driver code"
How can the above be solved in Python?
 ... Write me a code to elements that occurred only once in the array and the other steps required?
assistant
#Here is code to elements that occurred only once in the array and the other steps required.
 def occurredOnce ( arr , n ) :
	arr . sort ( )
	if arr [ 0 ] != arr [ 1 ] :
		print ( arr [ 0 ] , end = " ▁ " )
	for i in range ( 1 , n - 1 ) :
		if ( arr [ i ] != arr [ i + 1 ] and arr [ i ] != arr [ i - 1 ] ) :
			print ( arr [ i ] , end = " ▁ " )
	if arr [ n - 2 ] != arr [ n - 1 ] :
		print ( arr [ n - 1 ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
	arr = [ 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 ]
	n = len ( arr )
	occurredOnce ( arr , n )