Find index of the element differing in parity with all other array elements | Function to print the array element which differs in parity with the remaining array elements ; Multimaps to store even and odd numbers along with their indices ; Traverse the array ; If array element is even ; Otherwise ; If only one even element is present in the array ; If only one odd element is present in the array ;  ; Given array ; Size of the array
def OddOneOut ( arr , N ) : NEW_LINE INDENT e , o = { } , { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( arr [ i ] % 2 == 0 ) : NEW_LINE INDENT e [ arr [ i ] ] = i NEW_LINE DEDENT else : NEW_LINE INDENT o [ arr [ i ] ] = i NEW_LINE DEDENT DEDENT if ( len ( e ) == 1 ) : NEW_LINE INDENT print ( list ( e . values ( ) ) [ 0 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( list ( o . values ( ) ) [ 0 ] ) NEW_LINE DEDENT DEDENT / * Driver Code * / NEW_LINE arr = [ 2 , 4 , 7 , 8 , 10 ] NEW_LINE N = len ( arr ) NEW_LINE OddOneOut ( arr , N ) NEW_LINE