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 isPalindromic, which
- requires three parameter inputs, char array text, int startIndex, and int endIndex
- aims at determining whether the given sub-text from startIndex through endIndex is palindromic, with case insensitivity
- returns 1 if it is palindromic, 0 if it is not palindromic, -1 if the input char array text is null, -2 if the int startIndex is less than zero, or -3 if the int endIndex is greater than the length of the input char array text.
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.