Last Updated: 10 Nov, 2020

Morse Code To English

Easy
Asked in companies
AppleGoldman SachsAdobe

Approaches

01 Approach

  • The idea to approach the problem is to store the character and its morse code as pairs. Make a HashMap which contains key-value pairs (where key = MorseCode and value = Character Equivalent).
  • Split the given morse code on the basis of spaces and store them in a list.
  • Traverse the list and store the equivalent character element by element in an empty string named ans. (For java we will use StringBuffer for optimized string operations).
  • Return string ans as our answer.