Iterate over the array , arr [ ] and push the remaining occurrences of the elements into ans [ ]
for i in range ( N ) : NEW_LINE INDENT if ( i > 0 and arr [ i ] == arr [ i - 1 ] ) : NEW_LINE INDENT ans . append ( arr [ i ] ) NEW_LINE DEDENT DEDENT