← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Google SWE coding round with one problem that looked straightforward but had enough edge cases to keep me busy. The core idea was grouping numbers by shared digits, which sounds easy until you actually sit down and think through all the cases.

Questions Asked (1)

Q1

Given an array of two-digit numbers (up to 100 elements), find the largest subset where every number in the subset shares at least one digit that appears in all other numbers of the subset. For example, [55, 58, 25, 45] can form a group of 4 since the digit 5 appears in every member, but [55, 66, 77] cannot form such a group.

Algorithms & Data Structures
Author's notes

My first instinct was to think of this as a graph problem and I started going down that path before realizing there's a cleaner angle.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the problem reduces to finding the maximum number of two-digit numbers that all contain a common digit. Since there are only 10 possible digits, iterate through each digit 0-9, count how many numbers contain that digit, and return the maximum count. Discuss edge cases and potential follow-ups.

Pro tip: Mention that the solution is O(n) with a small constant factor (10 digits), and that you can optimize by precomputing digit masks for each number. Also, proactively discuss how to handle numbers with repeated digits (e.g., 55) and whether the subset must be contiguous (it does not).

1. Clarify the problem

Restate the problem in your own words and confirm with the interviewer that the subset is not required to be contiguous and that the common digit must appear in every number of the subset. Ask about edge cases like empty input or numbers with leading zeros.

2. Identify the key insight

Recognize that the condition 'shares at least one digit that appears in all other numbers' means there exists a single digit that is present in every number of the subset. Therefore, the problem reduces to finding the digit that appears in the most numbers.

3. Design the algorithm

Iterate through each possible digit (0-9). For each digit, count how many numbers in the array contain that digit. Keep track of the maximum count. Return the maximum count as the size of the largest subset.

4. Analyze complexity and edge cases

State that the time complexity is O(10 * n) = O(n) and space complexity is O(1). Discuss edge cases: empty array, numbers with repeated digits, and digits that appear in no numbers.

5. Test with examples

Walk through the given examples: [55, 58, 25, 45] yields 4 because digit 5 appears in all; [55, 66, 77] yields 2 because no digit appears in more than one number. Also test with a custom example to ensure correctness.

Key Points to Mention

  • The problem reduces to finding the digit with the maximum frequency across all numbers.
  • There are only 10 possible digits, so we can check each digit independently.
  • Time complexity is O(n) and space complexity is O(1).
  • Edge cases: empty array, numbers with repeated digits (e.g., 55), and digits that appear in no numbers.
  • The subset does not need to be contiguous; it is a subset of the array elements.
  • Potential follow-up: if the array size is large, we can use bitmasks to represent digits in each number for faster counting.

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