#3847
Find the Score Difference in a Game
pupil · 550 · lc medium +28 · 71.9% accepted · 43 likes · top 81%
Description
Given an integer array nums where nums[i] is the score from game i, two players alternate between active and inactive roles with the first player starting as active. For each game i, apply the following rules in order: if nums[i] is odd, swap active and inactive players; at every 6th game (indices 5, 11, 17, ...), swap again; then the currently active player earns nums[i] points. Return the first player's total score minus the second player's total score.
Code
1
2
3