public String longestPalindrome(String s) {

    if (s == null || s.length() == 0) {
      return s;
    }

    String longest = s.substring(0, 1);

    for (int i = 0 ; i < s.length() ; i++) {
      String p1 = helper(s, i, i);
      if (p1.length() > longest.length()) {
        longest = p1;
      }

      String p2 = helper(s, i, i + 1);
      if (p2.length() > longest.length()) {
        longest = p2;
      }
    }

    return longest;
  }