checkPalindrome
that takes the string s
and two indices i
and j
and checks if the substring s[i...j]
is a palindrome.left
at the start of the string (0) and right
at the end of the string (len(s) - 1
).left
is less than right
, compare the characters at s[left]
and s[right]
.
left
and decrement right
and continue.s[left+1...right]
or s[left...right-1]
is a palindrome using the helper function.