← Google Interview Insights

Google·Software Engineer·Online Assessment (OA)·Junior

Junior
Jun 2026

Summary

Google early career SWE online assessment, two problems in 90 minutes. The first problem here was the easier one, a digit-grouping thing, and the notes are pretty clear that you should knock it out fast and save your energy for the harder coin board problem.

Questions Asked (1)

Q1

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

Algorithms & Data Structures
Author's notes

This is the easier of the two problems on the assessment so you really want to finish it in under 5 minutes.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as finding the maximum frequency of any digit (0-9) across all numbers, since any subset where all numbers share a common digit must have that digit present in every number. Then, the size of the largest such subset is simply the maximum count of numbers containing a particular digit. This reduces the problem to a single pass through the list while maintaining a frequency array of size 10.

Pro tip: Clarify that the common digit must be the same across all numbers in the subset, and mention that if no digit appears in all numbers, the answer is at least 1 (any single number). Also, consider edge cases like numbers with repeated digits (e.g., 11) and ensure your solution handles them correctly without double-counting.

1. Understand the problem

Restate the problem to confirm that we need the largest subset where every number shares at least one common digit. Clarify that the common digit must be identical for all numbers in the subset.

2. Identify the key insight

Recognize that the problem reduces to finding the digit that appears in the most numbers. The size of the largest subset is the maximum frequency of any digit across all numbers.

3. Design the algorithm

Initialize a frequency array of size 10 for digits 0-9. For each number, extract its digits (tens and ones) and increment the corresponding frequency counts, ensuring each digit is counted only once per number.

4. Analyze complexity

State that the algorithm runs in O(n) time and O(1) space, where n is the number of integers, since we only traverse the list once and use a fixed-size array.

5. Handle edge cases and test

Discuss edge cases: empty list (return 0), single number (return 1), numbers with repeated digits (e.g., 11), and numbers that share no common digit with others (the maximum frequency will still be at least 1). Walk through a small example to verify.

Key Points to Mention

  • The problem reduces to finding the maximum frequency of any digit across all numbers.
  • Use a frequency array of size 10 to count occurrences of each digit.
  • Ensure each digit is counted only once per number to avoid overcounting.
  • Time complexity is O(n) and space complexity is O(1).
  • Edge cases: empty list, single element, numbers with repeated digits.
  • The answer is at least 1 if the list is non-empty, as any single number forms a valid subset.

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