Implement a tennis score tracker
Company: Aeonea
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
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.
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
- Track raw point counts for A and B; map counts 0,1,2,3 to 0,15,30,40.
- If both have at least 3 points: tie -> 'Deuce'; one-point lead -> 'Advantage'; two-point lead -> 'Game'.
- Stop appending results immediately after emitting a 'Game' result and ignore remaining characters.