Morse Code Palindromes
InterviewTime limit1sMemory limit1024 MB
Given one line of text, decide whether the Morse code of its letters and digits reads the same forwards and backwards.
- Level
Easy3 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
A palindrome is a word, number, phrase, or other sequence of characters that reads the same backward as forward, such as madam, racecar, or 1881. Phrase palindromes ignore capitalization, punctuation, and word boundaries. For example:
Madam I'm Adam.
Morse code is a method used in telecommunication to encode text characters as standardized sequences of two different signal durations, called dots and dashes, or dits and dahs. Morse code is named after Samuel Morse, one of the inventors of the telegraph. The international Morse code for letters and digits is shown below. Upper and lower case letters use the same code.

A word, number, or phrase is a Morse Code Palindrome if the Morse code for its letters and digits reads the same backward or forward, ignoring the spaces between character codes. For example:
159

Footstool

Write a program that takes a string as input and determines whether the string is a Morse Code Palindrome.
Input
The single input line contains a string of up to 80 characters. The string may include spaces and other non-alphanumeric printable characters.
Output
Print YES if the input string, ignoring everything except letters and digits, is a Morse Code Palindrome. Otherwise, print NO. If the input string has no letters or digits, print NO.