My first instinct was union-find but I second-guessed myself and started rambling about graphs.
Model the problem as a graph where each number is a node and edges connect numbers sharing a digit. The maximum subset is the largest connected component. Use union-find or BFS/DFS to find it efficiently.
Pro tip: Clarify whether the subset must be connected (i.e., every element shares a digit with at least one other in the subset) or just that no element is isolated. The former is the standard interpretation and leads to connected components.
Confirm that the subset must be connected: every element shares at least one digit with at least one other element in the subset. Also confirm if numbers are two-digit (10-99) and if duplicates are allowed.
Treat each number as a node. Add an edge between two numbers if they share at least one digit (tens or ones). The problem reduces to finding the largest connected component.
Use union-find (disjoint set) or BFS/DFS to find connected components. Union-find is efficient for large inputs; BFS/DFS is simpler to implement.
Instead of checking all pairs, map each digit (0-9) to the list of numbers containing it. Then union all numbers sharing a digit. This reduces time complexity.
Time: O(N * α(N)) with union-find and digit mapping, where N is the number of elements. Space: O(N). Handle edge cases: empty list, single element, no shared digits.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.