mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 15:01:40 +08:00
国外版
This commit is contained in:
42
算法题(国外版)/longest-chunked-palindrome-decomposition.html
Normal file
42
算法题(国外版)/longest-chunked-palindrome-decomposition.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<p>You are given a string <code>text</code>. You should split it to k substrings <code>(subtext<sub>1</sub>, subtext<sub>2</sub>, ..., subtext<sub>k</sub>)</code> such that:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>subtext<sub>i</sub></code> is a <strong>non-empty</strong> string.</li>
|
||||
<li>The concatenation of all the substrings is equal to <code>text</code> (i.e., <code>subtext<sub>1</sub> + subtext<sub>2</sub> + ... + subtext<sub>k</sub> == text</code>).</li>
|
||||
<li><code>subtext<sub>i</sub> == subtext<sub>k - i + 1</sub></code> for all valid values of <code>i</code> (i.e., <code>1 <= i <= k</code>).</li>
|
||||
</ul>
|
||||
|
||||
<p>Return the largest possible value of <code>k</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> text = "ghiabcdefhelloadamhelloabcdefghi"
|
||||
<strong>Output:</strong> 7
|
||||
<strong>Explanation:</strong> We can split the string on "(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)".
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> text = "merchant"
|
||||
<strong>Output:</strong> 1
|
||||
<strong>Explanation:</strong> We can split the string on "(merchant)".
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> text = "antaprezatepzapreanta"
|
||||
<strong>Output:</strong> 11
|
||||
<strong>Explanation:</strong> We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)".
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= text.length <= 1000</code></li>
|
||||
<li><code>text</code> consists only of lowercase English characters.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user