Skip to main content

Practice · 4 of 5

Palindrome check

CHALLENGE
Difficulty: beginner+25 XP

Implement boolean isPalindrome(String s): true when s reads the same forwards and backwards (case-sensitive; single chars and the empty string are palindromes). Compare s.charAt(i) with s.charAt(s.length() - 1 - i) — or reverse and equals.

Back to lesson: Practice: String surgery