mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 07:51:41 +08:00
update
This commit is contained in:
27
leetcode/problem/delete-operation-for-two-strings.html
Normal file
27
leetcode/problem/delete-operation-for-two-strings.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<p>Given two strings <code>word1</code> and <code>word2</code>, return <em>the minimum number of <strong>steps</strong> required to make</em> <code>word1</code> <em>and</em> <code>word2</code> <em>the same</em>.</p>
|
||||
|
||||
<p>In one <strong>step</strong>, you can delete exactly one character in either string.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> word1 = "sea", word2 = "eat"
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> word1 = "leetcode", word2 = "etco"
|
||||
<strong>Output:</strong> 4
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= word1.length, word2.length <= 500</code></li>
|
||||
<li><code>word1</code> and <code>word2</code> consist of only lowercase English letters.</li>
|
||||
</ul>
|
Reference in New Issue
Block a user