← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Google SWE coding round, one problem the whole session. Seemed straightforward at first glance but there's a bit more to it than brute force.

Questions Asked (1)

Q1

Given a list of two-digit integers, find the largest subset where every number shares at least one common digit across the entire subset.

Algorithms & Data Structures
Author's notes

My first instinct was to check pairs, which was completely wrong.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the problem reduces to finding the digit (0-9) that appears in the most numbers, since any valid subset must share at least one common digit. Then propose an efficient O(n) solution using a frequency array of size 10, and discuss edge cases like numbers with repeated digits and empty input.

Pro tip: Mention that you can solve it in one pass by updating a count array for each digit in each number, and that the maximum count directly gives the subset size. This shows you can optimize beyond brute force and handle large inputs gracefully.

1. Clarify the problem and constraints

Ask whether the subset must be contiguous, whether numbers can be used multiple times, and what to return if multiple digits tie. Confirm that the subset is defined by a single common digit shared by all numbers.

2. Identify the key insight

Realize that any valid subset corresponds to choosing a digit d that appears in every number of the subset. Therefore, the largest subset size is the maximum frequency of any digit across all numbers.

3. Design an efficient algorithm

Use a frequency array of size 10. For each two-digit number, extract its tens and units digits, and increment the count for each unique digit in that number. Track the maximum count seen.

4. Analyze complexity and edge cases

State that the algorithm runs in O(n) time and O(1) space. Discuss edge cases: empty list, numbers with repeated digits (e.g., 11), and ties where multiple digits yield the same maximum count.

5. Test with examples and conclude

Walk through a small example, such as [12, 23, 34, 45], to show the frequency counts and the resulting maximum subset size. Summarize the solution and its efficiency.

Key Points to Mention

  • The problem reduces to finding the most frequent digit across all numbers.
  • Use a frequency array of size 10 for digits 0-9.
  • Handle numbers with repeated digits (e.g., 11) by counting the digit only once per number.
  • Time complexity is O(n) and space complexity is O(1).
  • Edge cases: empty input, all numbers sharing no digit, and ties for maximum frequency.
  • The subset itself can be reconstructed by collecting all numbers containing the chosen digit.

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