A string is a palindrome if it reads the same forward and backward, with case insensitivity. For example, the words "mom", "dad", "Mom",...
X512: Text Palindromes
A string is a palindrome if it reads the same forward and backward, with case insensitivity. For example, the words "mom", "dad", "Mom", and "noon", for instance, are all palindromes.
A string is an array of characters or a sequence of characters, and thus, an array of characters is palindromic if and only if the left and right half subarrays are reversed.
Write a method, named as int isPalindromic(char[] text, int startIndex, int endIndex), which
- requires three parameter inputs,
char[] text,int startIndex, andint endIndex - aims at determining whether the given sub-text from
startIndexthroughendIndexis palindromic, with case insensitivity - returns 1 if it is palindromic, 0 if it is not palindromic, -1 if the input char array
textis null, -2 if the intstartIndexis less than zero, or -3 if the intendIndexis greater than the length of the input char arraytext.
To ignore the case sensitivity, we can convert each char variable to its upper case for character case-insensitivity comparison, through the method Character.toUpperCase(). For example,
char
f = 'a';
char fUpper = Character.toUpperCase(f);
Your Answer:
Feedback
Your feedback will appear here when you check your answer.