1. 思路:
  2. 暴力划分所有字符串两个for循环
  3. 调用是否回文函数
  4. 回文函数把字符串分两半然后charAt(i)
import java.util.*;

public class Solution {
    public int getLongestPalindrome(String A, int n) {
        // write code here
        //暴力解法
        int maxLen = 0;
        for(int i=0;i<A.length();i++){
            for(int j=i+1;j<=A.length();j++){
                String now = A.substring(i,j);
                if(isPalindrome(now) && now.length()>maxLen){
                    maxLen = now.length();
                }
            }
        }
        return maxLen;
    }
    public boolean isPalindrome(String now){
        int l = now.length();
        for(int i=0;i<l/2;i++){
            if(now.charAt(i) != now.charAt(l-i-1)){
                return false;
            }
        }
        return true;
    }
}