Created
March 27, 2019 21:47
-
-
Save Coffeegerm/d1d3940c9eeb0f99eb3e67c9a087aac7 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 palindrome(String string) | |
{ | |
return isPal(string, 0, string.length() - 1); | |
} | |
private boolean isPal(String string, int left, int right) | |
{ | |
if (left >= right) | |
{ | |
return true; | |
} | |
else if (string.charAt(left) == string.charAt(right)) | |
{ | |
return isPal(string, left + 1, right - 1); | |
} | |
else | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment