Palindrome Partitioning IV

Given a string s, determine whether it can be split into exactly three non-empty palindromic substrings. Pattern focus: Palindrome partitioning. This is a boolean partitioning variant that relies on precomputed palindrome states.

Input Format

s = input string

Output Format

true if s can be partitioned into exactly three palindromic substrings

Constraints

  • 3 <= s.length <= 2000
  • s contains lowercase English letters.

Examples

Example 1:

Input:

s = "abcbdd"

Output:

true

Explanation:

One valid split is a | bcb | dd.

Example 2:

Input:

s = "bcbddxy"

Output:

false

Explanation:

No split into exactly three palindromic substrings is possible.

Loading...
Palindrome Partitioning IV - Dp Strings