Numbersrebmun
Time limit1sMemory limit128 MB
Map each letter of a company name to its phone keypad digit, then check whether the resulting digit string reads the same forwards and backwards.
- Level
Easy2 of 10
- Topics
- String, Two pointers, Implementation
- Solved
- No attempts yet
Problem
Anna and Bob are starting a new high-tech company, and they want a memorable name. They love palindromes — words that read the same forwards and backwards, like their own names — but they cannot come up with a catchy company name that is also a palindrome.
So they settle for the next best thing: a phone number that is a palindrome. They want customers to be able to dial the company by spelling its name on a phone keypad, so the digits produced by typing the company name must form the phone number. On a standard phone keypad, the letters are grouped like this:
Given a company name, decide whether the phone number obtained by mapping each letter to its keypad digit is a palindrome. Letters may be uppercase or lowercase; the mapping ignores case.
Input
The first line contains an integer , the number of company names that follow. Each of the next lines contains one company name: a string of at most 20 letters, each either uppercase or lowercase.
Output
For each company name, print a single line containing YES if its phone number is a palindrome, or NO otherwise.