PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates string parsing, pattern matching, and combinatorial decoding skills using a Morse-to-letter mapping, covering both deterministic separator handling and enumeration of ambiguous letter partitions.

  • medium
  • Sealth
  • Coding & Algorithms
  • Software Engineer

Decode Ambiguous Morse Messages

Company: Sealth

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a mapping from Morse patterns to lowercase English letters. Implement two related functions: 1. **Deterministic decoding with character and word separators** - Input: a Morse-encoded string, a `char_sep` that separates letters inside a word, and a `word_sep` that separates words. - Output: the decoded sentence. - Example: if `char_sep` separates letters and `word_sep` separates words, decode the full message by splitting on words first and then on characters. 2. **Enumerate all valid decodings when character separators are missing** - Input: a Morse-encoded string that contains only a `word_sep` between encoded words, but no separator between letters inside each word. - Because each encoded word may be partitioned into letters in multiple valid ways, return **all possible decoded sentences** as a list or set. - For each encoded word, generate every valid letter sequence whose Morse concatenation matches that word exactly, then combine the per-word results into full-sentence outputs. Assume the Morse-to-letter dictionary is provided as part of the problem.

Quick Answer: This question evaluates string parsing, pattern matching, and combinatorial decoding skills using a Morse-to-letter mapping, covering both deterministic separator handling and enumeration of ambiguous letter partitions.

Decode Morse With Separators

Decode a Morse message using explicit character and word separators.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('.... . .-.. .-.. --- / .-- --- .-. .-.. -..', ' ', ' / ', {'....':'h','.':'e','.-..':'l','---':'o','.--':'w','.-.':'r','-..':'d'})

Expected Output: 'hello world'

Explanation: Decode with explicit character and word separators.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.

Enumerate Morse Decodings Without Character Separators

Return all decoded sentences when letters inside each word are not separated; output is sorted for deterministic grading.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('....../.-', '/', {'.':'e','-':'t','....':'h','..':'i','...':'s','.-':'a'})

Expected Output: ['eeeeee a', 'eeeeee et', 'eeeei a', 'eeeei et', 'eeeie a', 'eeeie et', 'eees a', 'eees et', 'eeh a', 'eeh et', 'eeiee a', 'eeiee et', 'eeii a', 'eeii et', 'eese a', 'eese et', 'ehe a', 'ehe et', 'eieee a', 'eieee et', 'eiei a', 'eiei et', 'eiie a', 'eiie et', 'eis a', 'eis et', 'esee a', 'esee et', 'esi a', 'esi et', 'hee a', 'hee et', 'hi a', 'hi et', 'ieeee a', 'ieeee et', 'ieei a', 'ieei et', 'ieie a', 'ieie et', 'ies a', 'ies et', 'ih a', 'ih et', 'iiee a', 'iiee et', 'iii a', 'iii et', 'ise a', 'ise et', 'seee a', 'seee et', 'sei a', 'sei et', 'sie a', 'sie et', 'ss a', 'ss et']

Explanation: Enumerate all decodings for each separator-delimited word.

Input: ('', '/', {'.':'e'})

Expected Output: ['']

Explanation: Empty encoded input has one empty sentence.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Related Coding Questions

  • Implement one-cluster k-means - Sealth (easy)
  • Simulate Threshold Grid Infection - Sealth (medium)

Loading coding console...

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
  • AI Coding 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.