181. Palindrome With a Deque
Core1000 ms256 MBSolved by 0%
Read one line and print Yes if it reads the same forwards and backwards,
or No otherwise.
IGNORE everything that is not a letter, and treat upper and lower case as the same. So
A man a plan a canal Panama is a palindrome.
A deque suits this exactly: compare the two ends, then remove both and repeat.
Constraints - The line has between 0 and 100000 characters. - Printable ASCII only.
Input
A single line of text. It may contain letters, spaces and punctuation.
Output
Print Yes if the letters read the same in both directions, or No if they do not.
Inputracecar
OutputYes
Noteis a plain palindrome with no spaces
InputA man a plan a canal Panama
OutputYes
Noteneeds spaces ignored and case folded before it reads as a palindrome
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.