Package g0001_0100.s0072_edit_distance
Class Solution
java.lang.Object
g0001_0100.s0072_edit_distance.Solution
72 - Edit Distance.<p>Hard</p>
<p>Given two strings <code>word1</code> and <code>word2</code>, return <em>the minimum number of operations required to convert <code>word1</code> to <code>word2</code></em>.</p>
<p>You have the following three operations permitted on a word:</p>
<ul>
<li>Insert a character</li>
<li>Delete a character</li>
<li>Replace a character</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> word1 = “horse”, word2 = “ros”</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> horse -> rorse (replace ‘h’ with ‘r’) rorse -> rose (remove ‘r’) rose -> ros (remove ‘e’)</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> word1 = “intention”, word2 = “execution”</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> intention -> inention (remove ‘t’) inention -> enention (replace ‘i’ with ‘e’) enention -> exention (replace ‘n’ with ‘x’) exention -> exection (replace ‘n’ with ‘c’) exection -> execution (insert ‘u’)</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= word1.length, word2.length <= 500</code></li>
<li><code>word1</code> and <code>word2</code> consist of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minDistance
-