3847. Find the Score Difference in a Game
You are given an integer array
nums, wherenums[i]represents the points scored in thei^thgame.There are exactlytwo players. Initially, the first player is active and the second player is inactive.
The following rules apply sequentially for each game
i:
- If
nums[i]is odd, the active and inactive players swap roles.- In every 6th game (that is, game indices
5, 11, 17, ...), the active and inactive players swap roles.- The active player plays the
i^thgame and gainsnums[i]points.Return the score difference, defined as the first player’s total score minus the second player’s total score.
1 | class Solution { |