BudiBadu Logo

Check Palindrome

String Easy 0 views
Like17

The objective is to evaluate whether the string s maintains structural identity when its character sequence is inverted. This verification requires a character-by-character symmetry check to determine if the string reads identically from start-to-finish and finish-to-start.

The final result must be a boolean indicator confirming whether the input possesses palindromic properties. This structural validation accounts for cases where character alignment must be perfectly mirrored across the central axis of the string.

Example 1:

Input: s = "madam"
Output: true

Example 2:

Input: s = "hello"
Output: false

Example 3:

Input: s = "racecar"
Output: true

Algorithm Flow

Recommendation Algorithm Flow for Check Palindrome - Budibadu
Recommendation Algorithm Flow for Check Palindrome - Budibadu

Best Answers

java
class Solution {
    public boolean is_palindrome(String s) {
        String rev = new StringBuilder(s).reverse().toString();
        return s.equals(rev);
    }
}