id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

isPalindrome


A String is said to be a palindrome if it remains unchanged when reversed.

Given the definition of the function that returns the reverse of a String, define a function that returns true if the String passed is a palindrome, false otherwise.

String reverse(String s) {
  String result = "";
  for(int i=0; i < s.length(); i++) {
    result = s.charAt(i) + result; //add later characters before earlier characters
  }
  return result;
}

isPalindrome("madam") → true
isPalindrome("") → true
isPalindrome("made! edam") → false

...Save, Compile, Run (ctrl-enter)

boolean isPalindrome(String s) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 1 Post-solution available

Copyright Nick Parlante 2017 - privacy