Approach hintTry it first, then revealHide
Every palindrome mirrors around a centre, which is either a character or the gap between two characters. Expand outward from each of the 2n - 1 centres while the ends match. O(n^2) time, O(1) space.
Every palindrome mirrors around a centre, which is either a character or the gap between two characters. Expand outward from each of the 2n - 1 centres while the ends match. O(n^2) time, O(1) space.