public String longestPalindrome(String s) {
		int n = s.length();
		int maxLength = 0;
		String maxString = "";
		for (int i = 0; i < n; i++) {
			int j = 0;
			while (i - j >= 0 && i + j < n
					&& s.charAt(i - j) == s.charAt(i + j)) {
				if (j * 2 + 1 > maxLength) {
					maxLength = j * 2 + 1;
					maxString = s.substring(i - j, i + j + 1);
				}
				j++;
			}

			j = 0;
			while (i - j >= 0 && i + 1 + j < n
					&& s.charAt(i - j) == s.charAt(i + 1 + j)) {
				if ((j + 1) * 2 > maxLength) {
					maxLength = (j + 1) * 2;
					maxString = s.substring(i - j, i + j + 2);
				}
				j++;
			}
		}
		return maxString;
	}