#K63247. Palindrome Checker
Palindrome Checker
Palindrome Checker
In this problem, you are given a number T followed by T strings. For each string, you need to determine whether it is a palindrome. A string is considered a palindrome if it reads the same forward and backward. Mathematically, a string \(S\) is a palindrome if and only if \(S = \text{reverse}(S)\). For example, "racecar" and "madam" are palindromes, while "hello" is not.
Your task is to check each string and print YES
if the string is a palindrome, and NO
otherwise.
The input will be provided via standard input (stdin) and the output should be printed to standard output (stdout), each result on a new line.
inputFormat
The first line contains an integer T
which indicates the number of test strings. The following T
lines each contain a single string to be checked.
Input Format:
Line 1: An integer T
.
Next T lines: Each line contains a string S
.
outputFormat
For each test case, print a single line containing YES
if the string is a palindrome, or NO
if it is not.
3
racecar
hello
madam
YES
NO
YES
</p>