import java.util.*; public class Solution { public int getLongestPalindrome (String A) { // write code here char[] arr = A.toCharArray(); int maxlen = 1; for (int i = 0; i < arr.length; i++) { for (int j = i+1; j < arr.length; j++) { if (isPalindrome(arr, i, j)){ int tmp = j - i + 1; if (tmp > maxlen) { maxlen = tmp; } } } } return maxlen; } boolean isPalindrome(char[] arr, int l, int r){ if (l == r){ return true; } if (l+1 == r){ return arr[l] == arr[r] ? true : false; } while (l < r){ if (arr[l++] != arr[r--]) { return false; } } return true; } }