Focus on the endpoints of your current range . If : both characters can be endpoints of a palindrome. The remaining problem is finding the LPS in , then adding for these matching endpoints.
If : at least one endpoint must be excluded. Either skip (solve ) or skip (solve ). Take the maximum. This gives us a clean two-case recurrence with no need to try all split points.