FastPrepTennis Game Winner
Problems/Tennis Game Winner

Tennis Game Winner

Capital One logoCapital One● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two Capital One intern reports from the United Kingdom, one from 2020 and one from 2022, name a tennis game coding question. The 2020 one describes the task as working out the winner of a game from its scores. The 2022 one gives only the name.

Neither says how the scores are given or what to return if the game is not over. Here you get each point's winner in order as a string of A and B. A player wins with at least 4 points and a lead of at least 2. You return an empty string while the game is still going. No point comes after the game is won. The limit on points is our choice.

Our version is about 75% the same as the reported questions.

Two players, A and B, play one game of tennis. The string points lists who won each point, in order.

A player wins the game once they have at least 4 points and at least 2 more points than the other player. Return "A" or "B" if that player has won. If nobody has won yet, return the empty string "".

The string stops at the latest when the game is won: no point is played after a player has won.

Function

tennisGameWinner(points: String) → String

Examples

Example 1

points = "ABBBAB"return = "B"

Tally after the six points: A has 2, B has 4. B reached 4 with a two-point margin, so the game went to B.

Example 2

points = "BAAABBBA"return = ""

A takes four of the eight points and B takes the other four, so the tally is 4 to 4. A one-point or zero-point gap is not enough to close a game, so the answer is "".

Example 3

points = "BBAAABAA"return = "A"

After seven points the tally is A 4, B 3, which is only a one-point gap. The eighth point goes to A, making it 5 to 3, and A takes the game.

Constraints

  • 1 <= points.length <= 1000
  • Each character of points is 'A' or 'B'.
  • No point comes after a player has won the game.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Document Edit EventsClickUp · ONSITE INTERVIEW
  • Predict Runtime Method DispatchAMD · ONSITE INTERVIEWAMD interview questions
  • Basic String Compression with Length GuardNew Relic · PHONE SCREEN · ONSITE INTERVIEW
  • Print Sentences as TableAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Retry with an Attempt LimitOracle · ONSITE INTERVIEWOracle interview questions
  • Extract Error Log ContextFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
  • Run-Length Encode Consecutive Letter RunsMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
  • String Pattern ReplacementGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 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
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public String tennisGameWinner(String points) {
        // Write your code here.
    }
}
Checking account…