Morse Code to English Problem Statement

You are provided with a string of morse code(s) of length N. Your task is to convert this morse code into the corresponding alphanumeric code consisting of lowercase English letters (a-z) and digits (0-9).

The Morse Code Table:

list = [ ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." ]

Note: list[0] corresponds to 'a', list[1] to 'b', and so on, up to list[35] which corresponds to '9'.

Input:

The first line contains an integer 'T' representing the number of test cases. Each test case is presented in the following lines:
Each test case consists of a string containing the morse code.

Output:

For every test case, output the corresponding alphanumeric string on a new line.

Example:

Input:
T = 2
".- -..."
"----."
Output:
ab
9
Constraints:
  • 1 <= T <= 10
  • 1 <= N <= 5*(10^5)

Note: You don't need to print anything. Implement the function accordingly.

AnswerBot
3d

Convert Morse code to alphanumeric code using a predefined table.

  • Iterate through the morse code string and convert each morse code to its corresponding alphanumeric character using the given table.

  • Joi...read more

Help your peers!
Add answer anonymously...
Goldman Sachs Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter