Longest Chunked Palindrome Decomposition
Return the largest possible k
such that there exists a_1, a_2, ..., a_k
such that:
Each
a_i
is a non-empty string;Their concatenation
a_1 + a_2 + ... + a_k
is equal totext
;For all
1 <= i <= k
,a_i = a_{k+1 - i}
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
text
consists only of lowercase English characters.1 <= text.length <= 1000
Last updated
Was this helpful?