Find the player who wins the game of placing alternate + and | Function to check which player wins the game ; Stores the difference between + ve and - ve array elements ; Traverse the array ; Update diff ; Checks if diff is even ; Driver Code ; Given Input ; Function call to check which player wins the game
def checkWinner ( arr , N ) : NEW_LINE INDENT diff = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT diff -= arr [ i ] NEW_LINE DEDENT if ( diff % 2 == 0 ) : NEW_LINE INDENT print ( " A " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " B " ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 2 ] NEW_LINE N = len ( arr ) NEW_LINE checkWinner ( arr , N ) NEW_LINE DEDENT