Editorial solution gives wrong answer for "aaabaa"


Editorial solution doesn’t work for “aaabaa” the correct answer is 1, the editorial answer says 4.
Slight modification to the solution below.

public int solve(String A) {
    int s = 0, e = A.length()-1;
    int add = 0;
    while (s < e)
        if (A.charAt(s) != A.charAt(e))
            s = add;
            e = A.length() - 1;
    return add;

Explanation of solution:
The way we check if a string is a palindrome is go with external pointers inward until they meet while the characters the pointers refer to are equal. If we meet a character which is not equal, we just assume we need to add one character to the end.
Now we know that the first character of the string and the last one are the same, so we repeat the process, but we offset the start pointer to the number of characters I have added to the end (we don’t need to check on those anymore) and we move the end pointer at the canonical length of the string (without counting the chars we have added), repeat the process until the pointers meet.

Runtime complexity O(N^2), because the number of characters we need to add grows linearly with the length of the string N, so it would be O(N*N)