Ten-Pin Bowling Frame Scores
Updated
Problem statement
A ten-pin bowling game has 10 frames. Each entry of rolls is how many pins one roll toppled, listed in play order for one finished game.
- In frames 1 to 9, a frame is over after a roll that topples all 10 pins (a
strike) or after two rolls. Two rolls that together topple exactly 10 pins make aspare. - A frame scores its own pins plus a bonus. A strike earns the pins of the two rolls after it in the list; a spare earns the pins of the one roll after it. Bonus rolls may lie in later frames, where they are counted again for those frames.
- Frame 10 always has two rolls and gets a third when it holds a strike or a spare. Its score is the sum of its own rolls, with no bonus.
Return an array of 10 integers: entry i is the running total of the scores of frames 1 to i + 1.
Function
bowlingScores(rolls: int[]) → int[]Examples
Example 1
rolls = [3,4,5,5,6,2,10,4,3,0,10,2,7,9,0,1,8,7,2]return = [7,23,31,48,55,67,76,85,94,103]Frame 1 scores 7. Frame 2 (5 and 5) clears all ten pins in two rolls, so it also earns the roll that follows, 6: 16, running total 23. Frame 3 scores 8 (31). Frame 4 clears everything with its first roll and earns the 4 and 3 that follow: 17 (48). Frame 5 scores 7 (55). Frame 6 (0 and 10) is cleared in two rolls and earns the 2 that follows: 12 (67). Frames 7 to 10 give 9 each: 76, 85, 94, 103.
Example 2
rolls = [10,10,10,10,10,10,10,10,10,10,10,10]return = [30,60,90,120,150,180,210,240,270,300]All 12 rolls topple ten pins. Each of frames 1 to 9 scores 10 plus the two rolls after it, 10 each, so 30; frame 9 borrows the first two rolls of frame 10. Frame 10 scores its own three rolls, 30, with no bonus, and the totals rise by 30 each frame up to 300.
Example 3
rolls = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,6,4,5]return = [0,0,0,0,0,0,0,0,20,35]Frames 1 to 8 topple nothing. Frame 9 clears all pins at once and earns the first two rolls of frame 10, 6 and 4: 20. Frame 10 (6 and 4) clears the rack in two rolls and gets a third roll of 5; it scores 6 + 4 + 5 = 15 and that last roll earns nothing more, so the final total is 35.
Constraints
12 <= rolls.length <= 210 <= rolls[i] <= 10rollsis a complete, legal game: frames 1 to 9 of two rolls never knock down more than 10 pins together, and frame 10 has exactly the rolls the rules above give it.
More Capital One interview questions
- Count Records Present in A but Not BPHONE SCREEN · Seen Oct 2026
- LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
- Maximum Subarray SumPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2025
- Min StackPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2023
- Invert a Binary TreePHONE SCREEN · Seen Dec 2020
- Count How Often a Word Appears in a ParagraphPHONE SCREEN
- In-Memory File System With Directory SizesPHONE SCREEN · ONSITE INTERVIEW
- Pick the K Nearest Grid Points to (0, 0)PHONE SCREEN · ONSITE INTERVIEW
- The Nth Number in the Fibonacci SequencePHONE SCREEN · ONSITE INTERVIEW
- Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
- Paginate Retained Conversation HistorySierra · PHONE SCREENSierra interview questions
- Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
- Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Apply Affine Array TransformationsByteDance · PHONE SCREENByteDance interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Bounded IPv4 FilterAmazon · PHONE SCREEN
- Partition and Group Values by ParityEPAM · PHONE SCREENEPAM interview questions
Capital One interview experiences
- Capital One Experienced Engineer Power Day and OA: 6 Experiences
- Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
- Capital One TDP Agentic Round (AI Coding): 7 Experiences
- Capital One SWE Power Day, Level Not Reported: 6 Experiences
- Capital One TIP Intern OA and Power Day: 13 Experiences
- Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)