Skip to content

Instantly share code, notes, and snippets.

@Coffeegerm
Created March 27, 2019 21:47
Show Gist options
  • Save Coffeegerm/d1d3940c9eeb0f99eb3e67c9a087aac7 to your computer and use it in GitHub Desktop.
Save Coffeegerm/d1d3940c9eeb0f99eb3e67c9a087aac7 to your computer and use it in GitHub Desktop.
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