#C1593. Palindrome Checker
Palindrome Checker
Palindrome Checker
You are given a string s
that consists of lowercase English letters and spaces. Your task is to determine whether the string is a palindrome when all spaces are ignored. In other words, after removing all spaces from the string, check if the string reads the same forward and backward.
Note: A single letter or an empty sequence of characters is considered a palindrome.
Examples:
racecar
becomesracecar
and is a palindrome so outputYES
.hello world
becomeshelloworld
which is not the same when reversed so outputNO
.
The check is performed by comparing the string (after removing spaces) with its reverse. In mathematical terms, if we denote the cleaned string as \( s' \), then the condition for the string being a palindrome is:
[ s' = \text{reverse}(s') ]
inputFormat
The input consists of a single line containing a string s
composed of lowercase English letters and spaces.
outputFormat
Print YES
if the string is a palindrome after ignoring spaces, otherwise print NO
.
racecar
YES