ExamAdda Logo

Check Whether a String Is a Palindrome

Easy

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

0 <= s.length <= 10^5

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

Chatla Jithin Sri Surya

Written by: Chatla Jithin Sri Surya

Chatla Jithin Sri Surya

Technically reviewed by: Chatla Jithin Sri Surya

Published

Oct 27, 2026

Last updated

Oct 27, 2026

Last technically reviewed

Oct 27, 2026

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.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output