Largest Group of Two-Digit Numbers Sharing Digits

Asked at Google · Coding Questions · Difficulty: Medium · Last asked May 7, 2026

You are given a list `nums` of two-digit numbers, each digit being from 1 to 9 (so values run from 11 to 99 with no zero digit). Two numbers are in the same group if they share at least one digit. Grouping is transitive: if `a` and `b` share a digit and `b` and `c` share a digit, then `a`, `b` and `c` are all in the same group, even if `a` and `c` share nothing.

Loading the problem…