Description
Solutions
Submission
Score Difference

Given the initial setup of a match between two players, evaluate the match's outcome.

There are two players, and there is a number sequence of size n. Players alternate turns for n rounds. Each round, a player removes the first number from the sequence and adds its value to their score. After that, if the "remvoed" number is even, the remaining sequence is reversed.

Determine the difference in scores between the two players after the game.

More precisely, suppose first_score and second_score are the final scores of the first and second player, respectively. The goal is to calculate the value of first_socre - second-score.

Example 1:

Input:  n = 5, numSeq = [3, 6, 2, 3, 5]
Output: 1
Explanation:

The number of elements is n = 5 and numSeq = [3, 6, 2, 3, 5].

  • 1st round: The first player picks 3, first_score = 3. The remaining sequence: [6, 2, 3, 5].
  • 2nd round: The second player picks 6, second_score = 6. Since 6 is even, the remaining sequence is reversed: [5, 3, 2].
  • 3rd round: The first player picks 5, first_score = 3 + 5 = 8. The remaining sequence: [3, 2].
  • 4th round: Second player picks 3, second_score = 6 + 3 = 9. The remaining sequence: [2].
  • 5th round (final): First player picks 2, second_score = 8 + 2 = 10. The remaining sequence [].
  • The total difference between players' scores is first_score - second_score = 10 - 9 = 1.

    Constraints:
      N/A (Pls feel free to let us know if you happen to know about it. TY!
    Testcase

    Result
    Case 1

    input:

    output: