← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Google SWE interview with a digit-matching array problem. Pretty clean problem once you see the trick, but I spent too long second-guessing myself on the approach.

Questions Asked (1)

Q1

Given a list of two-digit integers (10 to 99), find the maximum number of elements you can select such that all selected numbers share at least one common digit.

Algorithms & Data Structures
Author's notes

My first instinct was some kind of greedy with frequency counting, which was actually right but I took forever to convince myself.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the problem reduces to finding the digit (0-9) that appears in the most numbers, since any set of numbers sharing a common digit must all contain that digit. Count the frequency of each digit across all numbers, then return the maximum frequency. This yields an O(n) solution with O(1) extra space.

Pro tip: Clarify that numbers like 11 contain the same digit twice but should be counted once per digit; also mention that if no numbers are given, the answer is 0. This shows attention to edge cases and precision.

1. Understand the problem

Restate the problem: select the maximum subset of two-digit numbers such that all share at least one common digit. Note that the common digit must be the same across all selected numbers.

2. Identify the key insight

Realize that the problem reduces to finding the digit that appears in the most numbers. Because if a set of numbers shares a digit d, then every number in the set contains d, so the size of the set is at most the frequency of d.

3. Design the algorithm

Initialize an array of size 10 to count occurrences of each digit. For each number, extract its tens and units digits, and increment the count for each unique digit in that number (avoid double-counting if both digits are the same).

4. Compute and return the result

After processing all numbers, the answer is the maximum value in the digit count array. If the list is empty, return 0.

5. Analyze complexity and edge cases

Time complexity is O(n) since we process each number once. Space complexity is O(1) for the fixed-size count array. Discuss edge cases: empty list, numbers with repeated digits (e.g., 11), and ties (any digit with max count works).

Key Points to Mention

  • Reduction to digit frequency counting
  • Handling numbers with repeated digits (e.g., 11) by counting each digit once per number
  • Time and space complexity analysis (O(n) time, O(1) space)
  • Edge cases: empty input, all numbers sharing a digit, no common digit
  • Proof of correctness: any valid set corresponds to a digit, and the maximum set size equals the maximum digit frequency
  • Potential follow-up: what if numbers can have more than two digits? (Generalization to any number of digits)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.