Skip to content

Instantly share code, notes, and snippets.

@harrisonbrock
Created January 30, 2019 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harrisonbrock/f43765d2eb6bc86321ffd0f47ea7e18b to your computer and use it in GitHub Desktop.
Save harrisonbrock/f43765d2eb6bc86321ffd0f47ea7e18b to your computer and use it in GitHub Desktop.
public boolean isPalindrome(String word) {
// create array
char[] charArray = word.toCharArray();
// create two index start and end
for (int start = 0, end = word.length() - 1; start < end; ++start, --end){
// check if the two values are not the same
if(charArray[start] != charArray[end]) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment