Maximum Elements With a Common Digit
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Google OA, reported September 2026, is trying to find the biggest group by comparing numbers to each other. Don't. The question is really about digits. Every chosen number must share at least one digit, so the answer is the best single digit. You count how many numbers contain each digit 0-9 and return the largest count. It's a small counting problem dressed up as a grouping puzzle. If your brain freezes under the timer, StealthCoder runs invisibly as a safety net during the live OA and surfaces the approach so you aren't stuck staring at the screen.
The problem
An array numbers consists of N two-digit numbers. A group of numbers can be chosen from the array only if all of them share at least one digit. For example, 52, 25, and 55 can be chosen together because they share digit 5, while 11, 52, and 34 cannot be chosen together. Return the maximum number of array elements that can be chosen together. Implement solution(numbers). Function solution(numbers: int[]) → int Examples Example 1 numbers = [52, 25, 11, 52, 34, 55] return = 4 Elements 52, 25, 52, and 55 can be chosen. Example 2 numbers = [71, 23, 57, 15] return = 2 It is possible to choose at most two elements. Example 3 numbers = [11, 33, 55] return = 1 No two numbers share any digit. Example 4 numbers = [90, 90, 90] return = 3 All numbers can be chosen. Constraints N is an integer within the range [1..100]. Each element of array numbers is an integer within the range [10..99].
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: a group shares a common digit only if one digit appears in every member. So for each digit d from 0 to 9, count the numbers that contain d, and take the max. Each number is two digits, so check the tens and the units digit. The pitfall is double counting. A number like 55 or 11 contains digit 5 or 1 twice, but it's still one element, so add one per number, not one per digit occurrence. Check example 3: [11, 33, 55] gives a max count of 1, which matches. Example 4 gives 3 for digit 9. Use a set of the two digits per number, or compare tens and units before incrementing. Runtime is O(N) with a 10-slot array, and N is at most 100, so nothing fancy is needed. If you blank on the double count edge case during the live OA, StealthCoder is the hedge that catches it.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Maximum Elements With a Common Digit cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Elements With a Common Digit FAQ
How hard is the Google maximum elements with a common digit problem really?+
Easy once you see it. N is at most 100 and every number has two digits, so the only real hurdle is realizing the answer is the best single digit. Most of the difficulty is overthinking it into pairwise comparisons or subsets.
What's the trick to solving it fast?+
Loop digits 0 through 9. For each digit, count how many numbers contain it in the tens or units place. Return the biggest count. One pass over the array with a 10-slot counter does it, no sorting or grouping required.
What's the most common bug?+
Double counting numbers with a repeated digit, like 55 or 11. If you increment for both the tens and the units place, 55 counts twice for digit 5 and your answer inflates. Count each number once per digit, using a set or an equality check.
Do I need to worry about edge cases?+
Few. A single element returns 1. All distinct digit sets with no overlap return 1, like [11, 33, 55]. All identical numbers return N, like [90, 90, 90]. Digit 0 only appears as a units digit since numbers are 10 to 99.
How do I prepare for this in 48 hours?+
Practice digit extraction with divmod by 10, and frequency counting with a fixed array. Write this solution once from memory, then run the four given examples by hand. That covers it. Spend the rest of your time on other counting and hash-table style problems.