Class Solution
- java.lang.Object
-
- g1101_1200.s1147_longest_chunked_palindrome_decomposition.Solution
-
public class Solution extends Object
1147 - Longest Chunked Palindrome Decomposition.Hard
You are given a string
text. You should split it to k substrings(subtext1, subtext2, …, subtextk)such that:subtextiis a non-empty string.- The concatenation of all the substrings is equal to
text(i.e.,subtext1 + subtext2 + … + subtextk == text). subtexti == subtextk - i + 1for all valid values ofi(i.e.,1 <= i <= k).
Return the largest possible value of
k.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)(tpe)(za)(pre)(a)(nt)(a)”.
Constraints:
1 <= text.length <= 1000textconsists only of lowercase English characters.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
-
-
Method Detail
-
longestDecomposition
public int longestDecomposition(String text)
-
-