Google | Onsite | Encode & Decode Morse Code
Anonymous User
3926

Assuming a mapping for morse code to char (and vice versa) is available, write two functions:

  1. encode: Encodes a regular string into morse code string.
  2. decode: Returns all possible decoded message strings for a given morse code string.

Hypothetical mapping and examples:

{ 'A': '.', 'B': '-', 'C': '.-'}

encode('AB') -> '.-'
encode('C') -> '.-'
decode('.-') -> ['C', 'AB']

Closest conceptual LC equivalent is probably: https://leetcode.com/problems/decode-ways/

Comments (10)