Equalize Strings by Adding or Removing Characters at Ends
<p>Given two strings <code>initial</code> and <code>target</code>, your task is to modify <code>initial</code> by performing a series of operations to make it equal to <code>target</code>.</p>

<p>In one operation, you can add or remove <strong>one character</strong> only at the <em>beginning</em> or the <em>end</em> of the string <code>initial</code>.</p>

<p>Return the <strong>minimum</strong> number of operations required to <em>transform</em> <code>initial</code> into <code>target</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">initial = &quot;abcde&quot;, target = &quot;cdef&quot;</span></p>

<p><strong>Output:</strong> 3</p>

<p><strong>Explanation:</strong></p>

<p>Remove <code>&#39;a&#39;</code> and <code>&#39;b&#39;</code> from the beginning of <code>initial</code>, then add <code>&#39;f&#39;</code> to the end.</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">initial = &quot;axxy&quot;, target = &quot;yabx&quot;</span></p>

<p><strong>Output:</strong> 6</p>

<p><strong>Explanation:</strong></p>

<table border="1">
	<tbody>
		<tr>
			<th>Operation</th>
			<th>Resulting String</th>
		</tr>
		<tr>
			<td>Add <code>&#39;y&#39;</code> to the beginning</td>
			<td><code>&quot;yaxxy&quot;</code></td>
		</tr>
		<tr>
			<td>Remove from end</td>
			<td><code>&quot;yaxx&quot;</code></td>
		</tr>
		<tr>
			<td>Remove from end</td>
			<td><code>&quot;yax&quot;</code></td>
		</tr>
		<tr>
			<td>Remove from end</td>
			<td><code>&quot;ya&quot;</code></td>
		</tr>
		<tr>
			<td>Add <code>&#39;b&#39;</code> to the end</td>
			<td><code>&quot;yab&quot;</code></td>
		</tr>
		<tr>
			<td>Add <code>&#39;x&#39;</code> to the end</td>
			<td><code>&quot;yabx&quot;</code></td>
		</tr>
	</tbody>
</table>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">initial = &quot;xyz&quot;, target = &quot;xyz&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">0</span></p>

<p><strong>Explanation:</strong></p>

<p>No operations are needed as the strings are already equal.</p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= initial.length, target.length &lt;= 1000</code></li>
	<li><code>initial</code> and <code>target</code> consist only of lowercase English letters.</li>
</ul>
String; Binary Search; Dynamic Programming; Sliding Window; Hash Function
func minOperations(initial string, target string) int {
	m, n := len(initial), len(target)
	f := make([][]int, m+1)
	for i := range f {
		f[i] = make([]int, n+1)
	}
	mx := 0
	for i, a := range initial {
		for j, b := range target {
			if a == b {
				f[i+1][j+1] = f[i][j] + 1
				mx = max(mx, f[i+1][j+1])
			}
		}
	}
	return m + n - 2*mx
}