Given input string `aaaabaaa`

, I don't understand why the leetcode gives `aaaa`

as output while on my machine it correctly outputs `aaaabaaa`

.

```
class Solution:
def longestPalindrome(self, s):
n = len(s)
if n in [0, 1]:
return s
s2 = s[::-1]
for i in range(1, n+1):
for j in range(n, i, -1):
if i==1:
if s[:j] == s2[-j:]:
return s[:j]
else:
if s[i-1:j] == s2[-j:-i+1]:
return s[i-1:j]
```