My first instinct was to sort or group by digit, which is roughly right, but I spent too long thinking about it as a set intersection problem across all pairs.
Clarify that each number is two-digit (10-99) and that 'common digit' means at least one digit (0-9) appears in every selected number. Then, for each digit 0-9, count how many numbers contain that digit, and return the maximum count. This yields an O(n) solution with a small constant factor.
Pro tip: Mention that you can solve it in one pass by maintaining counts for each digit, and that the answer is simply the maximum frequency among digits. This shows you optimize for both time and space.
Confirm that numbers are two-digit, that 'common digit' means at least one digit shared by all selected numbers, and that we want the maximum subset size.
Realize that if a subset shares a common digit, that digit must be present in every number of the subset. So the problem reduces to finding the digit that appears in the most numbers.
Initialize an array of size 10 to zero. For each number, extract its tens and ones digits, and increment the counts for those digits (avoid double-counting if both digits are the same).
After processing all numbers, return the maximum value in the count array. This is the size of the largest subset sharing a common digit.
State that the algorithm runs in O(n) time and O(1) space (since the count array has fixed size 10), which is optimal.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.