Created
January 30, 2019 18:00
-
-
Save harrisonbrock/f43765d2eb6bc86321ffd0f47ea7e18b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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