Group words that map to same phone digits

Quick Overview

This question evaluates string processing, mapping and grouping competencies and the ability to design efficient encodings for detecting collisions, assessing practical application of algorithmic techniques. It is commonly asked in the Coding & Algorithms domain because it probes algorithmic efficiency, data-structure selection, and handling of input-size and performance constraints.

Group words that map to same phone digits

Company: LinkedIn

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem On a classic phone keypad (T9), letters map to digits: - `2: ABC`, `3: DEF`, `4: GHI`, `5: JKL`, - `6: MNO`, `7: PQRS`, `8: TUV`, `9: WXYZ` Given a list of lowercase words, convert each word into its digit string (e.g., `"tree" -> "8733"`). Return all **groups of words** that map to the **same digit string** (i.e., collisions). Only include groups of size `>= 2`. ## Input / Output - **Input:** `words: string[]` (lowercase a–z) - **Output:** A list of groups, where each group is a list of words sharing the same digit encoding. ## Constraints (typical) - `1 <= len(words) <= 2 * 10^5` - `1 <= len(word) <= 30` ## Examples - Input: `["tree", "used", "apple", "vase"]` - `tree -> 8733`, `used -> 8733`, `apple -> 27753`, `vase -> 8273` - Output: `[["tree", "used"]]`

Quick Answer: This question evaluates string processing, mapping and grouping competencies and the ability to design efficient encodings for detecting collisions, assessing practical application of algorithmic techniques. It is commonly asked in the Coding & Algorithms domain because it probes algorithmic efficiency, data-structure selection, and handling of input-size and performance constraints.

|Home/Coding & Algorithms/LinkedIn
LinkedIn logo
LinkedIn
Oct 20, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
8
0

Problem

On a classic phone keypad (T9), letters map to digits:

  • 2: ABC , 3: DEF , 4: GHI , 5: JKL ,
  • 6: MNO , 7: PQRS , 8: TUV , 9: WXYZ

Given a list of lowercase words, convert each word into its digit string (e.g., "tree" -> "8733").

Return all groups of words that map to the same digit string (i.e., collisions). Only include groups of size >= 2.

Input / Output

  • Input: words: string[] (lowercase a–z)
  • Output: A list of groups, where each group is a list of words sharing the same digit encoding.

Constraints (typical)

  • 1 <= len(words) <= 2 * 10^5
  • 1 <= len(word) <= 30

Examples

  • Input: ["tree", "used", "apple", "vase"]
    • tree -> 8733 , used -> 8733 , apple -> 27753 , vase -> 8273
    • Output: [["tree", "used"]]

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...