Known Words Matching Phone Digits
Updated
Problem statement
You are given a dictionary of known lowercase words and a string of telephone digits. Return the known words that exactly match the digit string using this mapping:
2:abc3:def4:ghi5:jkl6:mno7:pqrs8:tuv9:wxyz
A matching word has exactly one letter for every digit, and each letter maps to the digit at the same position. Return each matching word once, in alphabetical order. Return an empty array when there is no match.
Thread-safety discussion
Discuss how several callers could query a shared dictionary or lookup cache safely. Explain how to publish a complete dictionary snapshot, protect mutable shared state and avoid returning a cached answer from the wrong dictionary version. The judged callable remains a finite sequential lookup and does not require implementing threads.
Function
matchingWords(words: String[], digits: String) → String[]Examples
Example 1
words = ["tree","used","apple"]digits = "8733"return = ["tree","used"]Both tree and used map to 8733. apple has a different length and signature.
Example 2
words = ["a","b","a","d"]digits = "2"return = ["a","b"]The repeated dictionary entry a appears only once in the result.
Example 3
words = ["careers"]digits = "2273377"return = ["careers"]The letters of careers map to 2, 2, 7, 3, 3, 7, 7, matching 2273377.
Example 4
words = ["linkedin","linkedgo"]digits = "54653346"return = ["linkedgo","linkedin"]Both linkedin and linkedgo map to 54653346. The output places linkedgo before linkedin to follow this exercise's alphabetical-order rule.
Constraints
0 <= words.length <= 2000.- Every word contains
1to20lowercase English letters. 1 <= digits.length <= 20; every digit is from2through9.- Dictionary entries may repeat.
More LinkedIn Phone Screen questions
- Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
- Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
- Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
- Sqrt(x)PHONE SCREEN · Seen Nov 2026
- Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
- Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
- Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
- Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
- Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026
- Constant-Time Minimum StackPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- SimpleRDD Word CountDatologyAI · PHONE SCREEN