You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that:
Return the largest possible value of k.
Examples
Example 1
Input: text = "ghiabcdefhelloadamhelloabcdefghi"
Output: 7
Explanation: We can split the string on "(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)".
Example 2
Input: text = "merchant"
Output: 1
Explanation: We can split the string on "(merchant)".
Example 3
Input: text = "antaprezatepzapreanta"
Output: 11
Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tep)(za)(pre)(a)(nt)(a)".
Constraints
1 <= text.length <= 1000
text consists only of lowercase English characters.
1147. Longest Chunked Palindrome Decomposition
Hard
50 Points
Two Pointers
String
Dynamic Programming
Greedy
Rolling Hash
Hash Function
You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that:
Return the largest possible value of k.
Examples
Example 1
Input: text = "ghiabcdefhelloadamhelloabcdefghi"
Output: 7
Explanation: We can split the string on "(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)".
Example 2
Input: text = "merchant"
Output: 1
Explanation: We can split the string on "(merchant)".
Example 3
Input: text = "antaprezatepzapreanta"
Output: 11
Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tep)(za)(pre)(a)(nt)(a)".
Constraints
1 <= text.length <= 1000
text consists only of lowercase English characters.
Longest Chunked Palindrome Decomposition - Practice Coding | SlaveCode