Largest Digit Group

Asked at Google

Reported by the problem's creator, not verified

You are given a list nums of two-digit numbers. A digit appears in a number if it is its tens digit or its units digit, so 52 has the digits 5 and 2. A repeated number is a separate entry for each time it appears.

Examples

  1. Example 1

    Input: nums = [52,25,55,11,34]

    Output: 3

    Explanation: Digit 5 appears in 52, 25 and 55, so a group of 3 shares it. Digit 2 reaches only 52 and 25, and digit 1 reaches only 11.

  2. Example 2

    Input: nums = [11,21,31,41,16,17,18,34,57]

    Output: 7

    Explanation: Digit 1 appears in 11, 21, 31, 41, 16, 17 and 18, which is 7 numbers. 11 counts once even though it has two 1s.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.