Untitled
unknown
java
a year ago
677 B
12
Indexable
public class palindromeString { public static boolean checkExtremes(String str, int l, int r) { if (str.charAt(l) == str.charAt(r)) return true; return false; } public static boolean checkPalindrome(String str, int l, int r) { if (l >= r) return true; if (checkExtremes(str, l, r)) { return checkPalindrome(str, l + 1, r - 1); } return false; } public static void main(String[] args) { String checkPalidrome = "RACECAR"; System.out.println(checkPalindrome(checkPalidrome, 0, checkPalidrome.length() - 1)); } }
Editor is loading...
Leave a Comment