left
at 0 and right
at the length of the string minus 1.left
is less than right
:
a. If the characters at left
and right
are different, break the loop.
b. Store the character at left
in a variable c
.
c. Increment left
while the next character is the same as c
.
d. Decrement right
while the previous character is the same as c
and left
is not greater than right
.left
to right
, which is right - left + 1
.