Check Palindrome
Ever noticed how words like "racecar" or "level" read exactly the same backwards and forwards? In the world of coding, we call these Palindromes! Your task in this challenge is to take a string s and return true if it’s a perfect palindrome, and false otherwise.
The "secret sauce" here is Symmetry. While you could just reverse the string and compare it to the original, a more efficient way is to use Two Pointers. Think of it like two hikers: one starts at the beginning and the other at the end. As they walk together, they compare every character. If they ever hit a mismatch, boom—not a palindrome! If they meet in the middle without any errors, you’ve found a symmetrical word.
This challenge is a great way to master basic string manipulation and symmetry logic. It’s the gold standard for structural text inspection and data verification!
For binary-search-style logic, maintain strict pointer invariants and update boundaries carefully to avoid infinite loops or off-by-one mistakes. Decide early whether you need any valid match or a specific boundary match, then keep that contract consistent with the returned index semantics.
Examples
Example 1: "madam" reads the same forwards and backwards
Example 2: "hello" does not read the same backwards
Example 3: "racecar" is a palindrome
Algorithm Flow

Best Answers
class Solution {
public boolean is_palindrome(String s) {
String rev = new StringBuilder(s).reverse().toString();
return s.equals(rev);
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
