r/OfferEngineering • u/Aoki_zhang • 41m ago
Interview Experience Reddit Senior SWE Phone Screen - Design Tennis Game
This interview experience was originally shared on Chill Interview
Interview Summary
I recently completed a technical phone screen with Reddit. One of the coding questions was Design Tennis Game, an object-oriented simulation problem involving tennis scoring, deuce, advantage, and game-winning conditions.
Coding: Design a Tennis Scoring System
I was asked to implement a scoring system for a single tennis game between two players, A and B. Both players begin with zero points. Points are awarded one at a time, and the system must update the game state according to tennis scoring rules. The implementation must handle tied scores, deuce, advantage, and the condition for winning a game.
Part 1 — Implement the TennisGame Class
The required interface contained four methods:
1.
TennisGame()Initialize a new tennis game.- Player A starts with zero points.
- Player B starts with zero points.
- Neither player has won the game.
- 2.
pointTo(char player)Award one point to the specified player. The argument must be either'A'or'B'. If the game already has a winner, additional calls topointTo()must have no effect. 3.
getScore()Return the current numeric score as a string:"A:B". Here,AandBrepresent the number of points scored by each player. There is one special rule for deuce: When both players have scored at least three points and their scores are equal, the returned score must be"3:3"**.** For example: The implementation should preserve the internal scores while displaying the normalized score for deuce.- Internal score
3:3→"3:3" - Internal score
4:4→"3:3" - Internal score
6:6→"3:3"
- Internal score
4.
getWinner()Return the winner of the game:'A'if Player A has won.'B'if Player B has won.'#'if neither player has won.
Want to practice more real interview coding questions?
You can practice real interview coding questions at here.
Preparing for your next interview?
Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.