Leetcode Problem 2660. Determine the Winner of a Bowling Game

2660. Determine the Winner of a Bowling Game

Leetcode Solutions

Iterative Score Calculation

  1. Initialize scores for both players to 0.
  2. Iterate through the arrays from the first to the last turn.
  3. For each turn, check if the player scored a strike in the previous turn or the turn before that.
  4. If a strike was scored in the previous two turns, add double the current turn's score to the player's total score.
  5. Otherwise, add the current turn's score to the player's total score.
  6. After iterating through all turns, compare the total scores of both players.
  7. Return 1 if player1 has a higher score, 2 if player2 has a higher score, or 0 if there is a draw.
UML Thumbnail

Cumulative Score Tracking

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...