```
class Solution {
public:
string longestPalindrome(string s) {
const int length = s.length();
int start = 0;
int maxLength = 1;
bool palindromic[length][length];
for(int i = 0; i < length; i ++){
palindromic[i][i] = true;
if(i < length - 1 && s.at(i) == s.at(i + 1)){
palindromic[i][i + 1] = true;
start = i;
maxLength = 2;
}
}
for(int i = length - 1; i >= 0; i --)
for(int j = i + 2; j < length; j ++)
{
if(palindromic[i + 1][j - 1] == 1 && s.at(i) == s.at(j)){
palindromic[i][j] = 1;
int currentLength = j - i + 1;
if(currentLength > maxLength)
{
maxLength = currentLength;
start = i;
}
}
}
return string(s.substr(start, maxLength));
}
};
```

On the local machine, my program returns "aaabaaa", which is the right answer. However, Leetcode returns "aaabaaaa". Any clue is appreciated.