package main func getLongestPalindrome( A string ) int { n, ans := len(A), 1 var helper func(int, int) (int, int) helper = func(l, r int) (int, int) { for l >= 0 && r < n && A[l] == A[r] { l-- r++ } return l+1, r-1 } for i := 0; i < n; i++ { l1, r1 := helper(i, i) l2, r2 := helper(i, i+1) // abba if r1-l1+1 > ans { ans = r1-l1+1 } if r2-l2+1 > ans { ans = r2-l2+1 } } return ans }