Tap here to switch tabs
Problem
Submissions

Problem: Find the Score Difference in a Game

med
30 min
Try to solve the Find the Score Difference in a Game problem.

Statement

You are given an integer array nums representing the points available in a series of games. Two players, Player 11 and Player 22, take part in the games.

Initially, Player 11 is the active player, and both players have a score of 00.

The games are played sequentially from index 00 to nums.length −1- 1. For each game ii:

  • If nums[i] is odd, the active player switches to the other player.

  • If the game is every 6extth6^{ ext{th}} game (that is, (i+1)(i + 1) is divisible by 66), the active player switches to the other player.

  • The currently active player adds nums[i] points to their score.

Return the final score difference, defined as the score of Player 11 minus the score of Player 22.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Score Difference in a Game

med
30 min
Try to solve the Find the Score Difference in a Game problem.

Statement

You are given an integer array nums representing the points available in a series of games. Two players, Player 11 and Player 22, take part in the games.

Initially, Player 11 is the active player, and both players have a score of 00.

The games are played sequentially from index 00 to nums.length −1- 1. For each game ii:

  • If nums[i] is odd, the active player switches to the other player.

  • If the game is every 6extth6^{ ext{th}} game (that is, (i+1)(i + 1) is divisible by 66), the active player switches to the other player.

  • The currently active player adds nums[i] points to their score.

Return the final score difference, defined as the score of Player 11 minus the score of Player 22.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤1000\leq 1000