@@ -0,0 +1,1891 @@
+package algorithms.strings;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * You are given a string of lower case letters. Your task is to figure out the%0D%0A * index of the character on whose removal it will make the string a palindrome.%0D%0A * There will always be a valid solution.%0D%0A * %0D%0A * In case the string is already a palindrome, then -1 is also a valid answer%0D%0A * along with possible indices.%0D%0A * %0D%0A * Input Format: %0D%0A * The first line contains T, i.e. the number of test cases.%0D%0A * T lines follow, each containing a string.%0D%0A * %0D%0A * Output Format: %0D%0A * Print the position (0 index) of the letter by removing which the string turns%0D%0A * into a palindrome. For a string, such as%0D%0A * %0D%0A * bcbc%0D%0A * we can remove b at index 0 or c at index 3. Both answers are accepted.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= T %3C= 20%0D%0A * 1 %3C= length of string %3C= 100005%0D%0A * All characters are Latin lower case indexed.%0D%0A * %0D%0A * Sample Input: %0D%0A * 3%0D%0A * aaab%0D%0A * baa%0D%0A * aaa%0D%0A * %0D%0A * Sample Output: %0D%0A * 3%0D%0A * 0%0D%0A * -1%0D%0A */%0D%0Apublic class PalindromeIndex %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        %0D%0A        Scanner sc = new Scanner(System.in);%0D%0A        %0D%0A        int numCases = sc.nextInt();%0D%0A        %0D%0A        for (int i = 0; i %3C numCases; i++) %7B%0D%0A            String input = sc.next();%0D%0A            System.out.println(indexOfLetterToRemove(input));%0D%0A        %7D%0D%0A        sc.close();%0D%0A    %7D%0D%0A    %0D%0A    private static int indexOfLetterToRemove(String str) %7B%0D%0A        %0D%0A        int len = str.length();%0D%0A        %0D%0A        for (int i = 0; i %3C len; i++) %7B%0D%0A            if (str.charAt(i) == str.charAt(len - 1 - i)) %7B%0D%0A            %09continue;%0D%0A            %7D else if (str.charAt(i) == str.charAt(len - 2 - i) &&%0D%0A                      str.charAt(i + 1) == str.charAt(len - 3 - i)) %7B%0D%0A                return len - 1 - i;%0D%0A            %7D%0D%0A            return i;%0D%0A        %7D%0D%0A        return -1;%0D%0A    %7D%0D%0A%7D

Add PalindromeIndex