Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Longest Chunked Palindrome Decomposition

XPChallenge Points: 30
levelLevel: Hard

You are given a string text.
You need to break it into several non-empty pieces such that:

  • All pieces concatenated together form the original string.

  • The first piece must be equal to the last piece,
    the second piece equals the second last, and so on.

Your goal is to maximize the number of pieces formed this way.

Return the maximum number of such symmetric chunks.

Example 1:

Input: text = "abcxyzabc"

Output: 3

Explanation:

Split → ("abc")("xyz")("abc")

Example 2:

Input: text = "aaaa"

Output: 4

Explanation:

Split → ("a")("a")("a")("a")

Example 3:

Input: text = "level"

Output: 1

Explanation:

No symmetric chunking is possible except the whole string.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result