Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Determine the Winner of a Bowling Game

XPChallenge Points: 13
levelLevel: Easy

You are given two integer arrays, player1 and player2, each of length n, where each element represents how many pins a player knocked down in that specific turn.

Every turn has exactly 10 pins available to knock down.

Let a player score x pins in turn i. The value of that turn is:

  • 2 * x if the player had a strike (10 pins) in either of the previous two turns (i - 1 or i - 2).

  • Otherwise, the value of that turn is simply x.

A player's final score is the sum of all their turn values.

Return:

  • 1 if Player 1’s score is greater,

  • 2 if Player 2’s score is greater,

  • 0 if both scores are equal.

Example 1:

Input: player1 = [4,10,5,1] player2 = [6,3,7,2]

Output: 1

Example 2:

Input: player1 = [10,2,3] player2 = [5,4,6]

Output: 1

Example 3:

Input: player1 = [8,1,1] player2 = [4,5,1]

Output: 0

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result