Check Whether a String Is a Palindrome
Given a string s, determine whether it is a palindrome. A palindrome is a string that reads the same forward and backward.
Return true if the string is a palindrome; otherwise, return false.
For this problem, consider the string exactly as given. Case, spaces, and special characters matter.
Example 1
Input
s = "madam"
Output
true
Explanation
"madam" reads the same forward and backward.
Example 2
Input
s = "hello"
Output
false
Explanation
"hello" reversed is "olleh".
Constraints
Hints:
Hint 1
Compare the first and last characters of the string.
Hint 2
Move both pointers toward the center. If any pair of characters differs, the string is not a palindrome.
Author & Technical Reviewer
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output