PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to implement stateful scoring logic and choose appropriate data structures for tracking sequential events, specifically handling tennis scoring rules such as 0/15/30/40 progression, Deuce, Advantage, and the two-point lead requirement.

  • Medium
  • Aeonea
  • Coding & Algorithms
  • Software Engineer

Implement a tennis score tracker

Company: Aeonea

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Design and implement a tennis game scoring function. Input: a stream of points won by players 'A' or 'B' (e.g., A, B, B, B, B). After each point, output the current score in tennis notation: 'A 15-0 B', 'A 15-15 B', 'A 15-30 B', 'A 15-40 B', and finally the game result. Handle 0/15/30/40 progression, Deuce, Advantage, and Game with the correct two-point lead rule. Specify your data structures and update logic, and provide the outputs for the given example sequence.

Quick Answer: This question evaluates a candidate's ability to implement stateful scoring logic and choose appropriate data structures for tracking sequential events, specifically handling tennis scoring rules such as 0/15/30/40 progression, Deuce, Advantage, and the two-point lead requirement.

Given a string points consisting of characters 'A' and 'B' representing the winner of each point in a single tennis game, return a list of the score after each processed point using tennis notation. Use 'A X-Y B' for normal scores where X,Y in {0,15,30,40}. When both players have at least 3 points and are tied, output 'Deuce'. When both have at least 3 and one leads by one point, output 'Advantage A' or 'Advantage B'. When a player has at least 4 points and leads by at least 2, output 'Game A' or 'Game B' and stop processing further characters (ignore any remaining input).

Constraints

  • 1 <= len(points) <= 100000
  • points[i] is either 'A' or 'B'
  • The sequence contains at least the points up to and including the first 'Game' result; any extra characters after 'Game' must be ignored
  • Output after each processed point using exactly one of: 'A X-Y B', 'Deuce', 'Advantage A', 'Advantage B', 'Game A', 'Game B'

Examples

Input: ABBBB

Expected Output:

Input: AAAAA

Expected Output:

Input: ABABABABBB

Expected Output:

Input: BBBAAABB

Expected Output:

Input: AABABBABAA

Expected Output:

Hints

  1. Track raw point counts for A and B; map counts 0,1,2,3 to 0,15,30,40.
  2. If both have at least 3 points: tie -> 'Deuce'; one-point lead -> 'Advantage'; two-point lead -> 'Game'.
  3. Stop appending results immediately after emitting a 'Game' result and ignore remaining characters.
Last updated: Mar 29, 2026

Related Coding Questions

  • Find two numbers summing to target - Aeonea (Medium)

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.