The Determine the Winner of a Bowling Game interview question asks you to calculate the scores of two players based on a sequence of rolls. The twist is a special "multiplier" rule: if a player hits 10 pins in any of their previous two turns, their current turn's score is doubled. You need to return 1 if Player 1 wins, 2 if Player 2 wins, or 0 if it's a draw.
DE Shaw uses this "Easy" question to evaluate a candidate's attention to detail and ability to implement a set of rules accurately. It tests your proficiency with simulation interview patterns and array traversal. The logic requires you to maintain a "window" of previous rolls to decide the current multiplier, which is a common task in game logic and financial auditing systems.
This problem uses Linear Simulation.
calculateScore(rolls) to avoid code duplication.rolls[i-1] == 10 or rolls[i-2] == 10.Player 1: [5, 10, 3, 2]
Modularize your code. Even for simple problems, separating the "Scoring Logic" into its own function makes the main "Comparison Logic" much cleaner and reduces bugs.