Count Distinct Concatenated Morse Encodings

Quick Overview

Count Distinct Concatenated Morse Encodings. Encode each lowercase word by concatenating the Morse strings of its letters without separators.

Count Distinct Concatenated Morse Encodings

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Encode each lowercase word by concatenating the Morse strings of its letters without separators. Return the number of different encoded strings. In alphabetic order a through z, use this complete table: ```text [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] ``` ```cpp class Solution { public: int uniqueMorseRepresentations(vector<string>& words); }; ``` ### Examples **Example 1:** ```text words = ["e","t","et"] Output: 3 Explanation: Their encodings are ".", "-" and ".-". ``` **Example 2:** ```text words = ["a","et"] Output: 1 Explanation: Both encode to ".-" because no separator is inserted. ``` ### Constraints - There are 1 through 100 words. - Each word has 1 through 12 lowercase English letters. ### Contract considerations Use the complete exact mapping table. ```hint Read the boundary condition Can two different word spellings have the same concatenation? ``` ### Boundary reminders Use the complete exact mapping table.

Overview: Count Distinct Concatenated Morse Encodings. Encode each lowercase word by concatenating the Morse strings of its letters without separators.

Google logo
Google
Jun 28, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Encode each lowercase word by concatenating the Morse strings of its letters without separators. Return the number of different encoded strings. In alphabetic order a through z, use this complete table:

[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
class Solution {
public:
    int uniqueMorseRepresentations(vector<string>& words);
};

Examples

Example 1:

words = ["e","t","et"]
Output: 3
Explanation: Their encodings are ".", "-" and ".-".

Example 2:

words = ["a","et"]
Output: 1
Explanation: Both encode to ".-" because no separator is inserted.

Constraints

  • There are 1 through 100 words.
  • Each word has 1 through 12 lowercase English letters.

Contract considerations

Use the complete exact mapping table.

Boundary reminders

Use the complete exact mapping table.