PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Find largest group of two-digit numbers sharing digits

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to model pairwise relationships and compute connected components in small graphs, testing skills in graph connectivity and grouping based on shared attributes in arrays of two-digit numbers.

  • easy
  • Google
  • Coding & Algorithms
  • Software Engineer

Find largest group of two-digit numbers sharing digits

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

You are given an integer array `A` of length `n` (`1 <= n <= 100`). Each element is a two-digit number (e.g., from 10 to 99). Two numbers are considered **connected** if they share **at least one digit** in common. Examples of “share a digit”: - `55` and `58` share digit `5` - `25` and `45` share digit `5` - `12` and `23` share digit `2` - `55` and `66` share no digit A **group** is any set of numbers that can be connected through this relation transitively (i.e., if `a` shares a digit with `b`, and `b` shares a digit with `c`, then `a`, `b`, `c` can be in the same group even if `a` and `c` don’t share a digit directly). Task: Return the **maximum possible size** of a group (i.e., the size of the largest connected component under the “shares a digit” relation). Output: an integer, the largest group size. Clarifications: - If `A` contains duplicate values, treat them as separate elements (they each contribute 1 to the group size). - Sharing can be via either the tens digit or the ones digit.

Quick Answer: This question evaluates a candidate's ability to model pairwise relationships and compute connected components in small graphs, testing skills in graph connectivity and grouping based on shared attributes in arrays of two-digit numbers.

Related Interview Questions

  • Infection Spread on a Grid (Cellular Automaton) - Google (hard)
  • Streaming Points: Remove Any Pair Within a Distance - Google (medium)
  • Boolean Expression Tree with Leaf Flips - Google (medium)
  • Most Active Users in a Live Communication Stream - Google (medium)
  • Solve Rooms and Top-K Streams - Google (medium)
Google logo
Google
Dec 5, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
14
0

You are given an integer array A of length n (1 <= n <= 100). Each element is a two-digit number (e.g., from 10 to 99). Two numbers are considered connected if they share at least one digit in common.

Examples of “share a digit”:

  • 55 and 58 share digit 5
  • 25 and 45 share digit 5
  • 12 and 23 share digit 2
  • 55 and 66 share no digit

A group is any set of numbers that can be connected through this relation transitively (i.e., if a shares a digit with b, and b shares a digit with c, then a, b, c can be in the same group even if a and c don’t share a digit directly).

Task: Return the maximum possible size of a group (i.e., the size of the largest connected component under the “shares a digit” relation).

Output: an integer, the largest group size.

Clarifications:

  • If A contains duplicate values, treat them as separate elements (they each contribute 1 to the group size).
  • Sharing can be via either the tens digit or the ones digit.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.