package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/palindrome-index
 */
public class PalindromeIndex {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // TODO
    }
}

@@ -147,108 +147,1569 @@
    p
-ublic static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        // TODO
+rivate static int palindromeIndex(String str) %7B%0A        int idx = -1;%0A        for (int i = 0, j = str.length() - 1; i %3C j; i++, j--) %7B%0A            if (str.charAt(i) != str.charAt(j)) %7B%0A                boolean found = true;%0A                // remove left%0A                for (int left = i + 1, right = j; left %3C right; left++, right--) %7B%0A                    if (str.charAt(left) != str.charAt(right)) %7B%0A                        found = false;%0A                        break;%0A                    %7D%0A                %7D%0A                if (found) %7B%0A                    return i;%0A                %7D%0A                found = true;%0A                // remove right%0A                for (int left = i, right = j - 1; left %3C right; left++, right--) %7B%0A                    if (str.charAt(left) != str.charAt(right)) %7B%0A                        found = false;%0A                        break;%0A                    %7D%0A                %7D%0A                if (found) %7B%0A                    return j;%0A                %7D%0A            %7D%0A        %7D%0A        return idx;%0A    %7D%0A%0A    private static boolean isPalindrome(String str) %7B%0A        for (int i = 0, j = str.length() - 1; i %3C j; i++, j--) %7B%0A            if (str.charAt(i) != str.charAt(j)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        int testCases = in.nextInt();%0A        for (int t = 0; t %3C testCases; t++) %7B%0A            String str = in.next();%0A            System.out.println(palindromeIndex(str));%0A        %7D
 %0A   

Solve Palindrome Index