public String longestPalindrome(String s) {
        if (s == null) return null;
        String res = "";
        for (int i = 0; i < s.length(); ++i) {
            String s1 = expand(s, i, i);
            String s2 = expand(s, i, i + 1);
            if (s1.length() > res.length() || s2.length() > res.length()) {
                res = s1.length() > s2.length() ? s1 : s2;
            }
        }
        return res;
    }