FastPrepCount Player Teams by Shared Letters
Problems/Count Player Teams by Shared Letters

Count Player Teams by Shared Letters

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand report is from an on-campus intern interview in India. It asks for the number of teams when players who share a letter are connected. It also records the 26-letter DSU optimization. The report does not keep that input is lowercase, what happens with empty input, the input limits, or that links carry on through other players. Our version is about 95% the same as the reported question.

You are given an array players, where each string is the lowercase English name of one player.

Two players are directly connected when their names contain at least one common letter. A team is a connected component under this rule: players connected through other players belong to the same team even if their own names share no letter.

Return the number of teams.

Function

countPlayerTeams(players: String[]) → int

Examples

Example 1

players = ["ab","bc","de","ef"]return = 2

The first two names form one team through b. The last two form another through e.

Example 2

players = ["abc","cde","efg"]return = 1

The first and second names share c, and the second and third share e. Transitivity puts all three players on one team.

Example 3

players = ["amy","bob","cyd"]return = 2

Amy and Cyd share y. Bob has no letter in common with either of them.

Constraints

  • 0 <= players.length <= 200000.
  • Every name has length between 1 and 100.
  • Names contain only lowercase English letters.
  • The sum of all name lengths is at most 2000000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Record Linkage Part 3 - Full Connected ComponentStripe · PHONE SCREENStripe interview questions
  • Sentence Equivalence with SynonymsRead AI · PHONE SCREEN
  • Count Distinct Word MeaningsDuolingo · OADuolingo interview questions
  • Evaluate DivisionPlaud · ONSITE INTERVIEW
  • Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Count Friend CirclesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Radar Barrier CrossingSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Minimum Cost for Roads and HospitalsAmazon · ONSITE INTERVIEW
  • Validate and Complete Racer PrecedenceMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Accounts MergeOracle · ONSITE INTERVIEWOracle interview questions

Interview reports that mention this question

  • Google SWE Intern OA and Interviews: 42 Experiences (Part 1 of 3)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int countPlayerTeams(String[] players) {
        // Write your code here.
    }
}
Checking account…