Tap here to switch tabs
Problem
Submissions

Problem: Determine the Winner of a Bowling Game

med
30 min
Try to solve the Determine the Winner of a Bowling Game problem.

Statement

You are given two 00 indexed integer arrays player1 and player2, representing the number of pins knocked down by player 11 and player 22 in a bowling game consisting of nn turns.

The score of a player is calculated as the sum of points awarded in each turn. The points awarded in turn i are defined as:

  • 2imes2 imes player1[i] (or 2imes2 imes player2[i]) if the player knocked down 1010 pins in turn i−1i - 1 or turn i−2i - 2.

  • 1imes1 imes player1[i] (or 1imes1 imes player2[i]) otherwise.

Determine the winner of the game:

  • Return 11 if the total score of player 11 is strictly greater than the total score of player 22.

  • Return 22 if the total score of player 22 is strictly greater than the total score of player 11.

  • Return 00 if both players have the same total score.

Constraints:

  • n == player1.length == player2.length

  • 1≤1 \leq n ≤1000\leq 1000

  • 0≤0 \leq player1[i], player2[i] ≤10\leq 10

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Determine the Winner of a Bowling Game

med
30 min
Try to solve the Determine the Winner of a Bowling Game problem.

Statement

You are given two 00 indexed integer arrays player1 and player2, representing the number of pins knocked down by player 11 and player 22 in a bowling game consisting of nn turns.

The score of a player is calculated as the sum of points awarded in each turn. The points awarded in turn i are defined as:

  • 2imes2 imes player1[i] (or 2imes2 imes player2[i]) if the player knocked down 1010 pins in turn i−1i - 1 or turn i−2i - 2.

  • 1imes1 imes player1[i] (or 1imes1 imes player2[i]) otherwise.

Determine the winner of the game:

  • Return 11 if the total score of player 11 is strictly greater than the total score of player 22.

  • Return 22 if the total score of player 22 is strictly greater than the total score of player 11.

  • Return 00 if both players have the same total score.

Constraints:

  • n == player1.length == player2.length

  • 1≤1 \leq n ≤1000\leq 1000

  • 0≤0 \leq player1[i], player2[i] ≤10\leq 10