151. Check if String is Palindrome

EasyStringString

Given a string s, determine whether it is a palindrome.

A string is a palindrome if it reads the same forward and backward.
The check is case-sensitive and includes spaces and special characters.

Input: A single string s.

Output: Return 'true' if the string is a palindrome, otherwise return 'false'.

Examples

Example 1
Input: racecar
Output: true
Explanation: 'racecar' reversed is 'racecar' — same string, so it is a palindrome.
Example 2
Input: hello
Output: false
Explanation: 'hello' reversed is 'olleh' which is different, so it is not a palindrome.
Example 3
Input: a
Output: true
Explanation: A single character is always a palindrome.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →