Game of replacing array elements | Function return which player win the game ; Create hash that will stores all distinct element ; Traverse an array element ; Driver code
def playGame ( arr , n ) : NEW_LINE INDENT s = set ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT s . add ( arr [ i ] ) NEW_LINE DEDENT return 1 if len ( s ) % 2 == 0 else 2 NEW_LINE DEDENT arr = [ 1 , 1 , 2 , 2 , 2 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( " Player " , playGame ( arr , n ) , " Wins " ) NEW_LINE