mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part2
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<p>Oh, no! You have accidentally removed all spaces, punctuation, and capitalization in a lengthy document. A sentence like "I reset the computer. It still didn't boot!" became "iresetthecomputeritstilldidntboot''. You'll deal with the punctuation and capi­talization later; right now you need to re-insert the spaces. Most of the words are in a dictionary but a few are not. Given a dictionary (a list of strings) and the document (a string), design an algorithm to unconcatenate the document in a way that minimizes the number of unrecognized characters. Return the number of unrecognized characters.</p>
|
||||
|
||||
<p><strong>Note: </strong>This problem is slightly different from the original one in the book.</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>Example: </strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input: </strong>
|
||||
dictionary = ["looked","just","like","her","brother"]
|
||||
sentence = "jesslookedjustliketimherbrother"
|
||||
<strong>Output: </strong> 7
|
||||
<strong>Explanation: </strong> After unconcatenating, we got "<strong>jess</strong> looked just like <strong>tim</strong> her brother", which containing 7 unrecognized characters.
|
||||
</pre>
|
||||
|
||||
<p><strong>Note: </strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>0 <= len(sentence) <= 1000</code></li>
|
||||
<li><code><font face="sans-serif, Arial, Verdana, Trebuchet MS">The total number of characters in </font>dictionary</code> is less than or equal to 150000.</li>
|
||||
<li>There are only lowercase letters in <code>dictionary</code> and <code>sentence</code>.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user