1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 11:21:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part1

This commit is contained in:
2022-03-27 20:37:52 +08:00
parent 8e542045d1
commit c554fc6908
1285 changed files with 108123 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<p>给你两个长度相同的字符串,<code>s</code><code>t</code></p>
<p><code>s</code> 中的第 <code>i</code> 个字符变到 <code>t</code> 中的第 <code>i</code> 个字符需要 <code>|s[i] - t[i]|</code> 的开销(开销可能为 0也就是两个字符的 ASCII 码值的差的绝对值。</p>
<p>用于变更字符串的最大预算是 <code>maxCost</code>。在转化字符串时,总开销应当小于等于该预算,这也意味着字符串的转化可能是不完全的。</p>
<p>如果你可以将 <code>s</code> 的子字符串转化为它在 <code>t</code> 中对应的子字符串,则返回可以转化的最大长度。</p>
<p>如果 <code>s</code> 中没有子字符串可以转化成 <code>t</code> 中对应的子字符串,则返回 <code>0</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "abcd", t = "bcdf", maxCost = 3
<strong>输出:</strong>3
<strong>解释:</strong>s<strong> </strong>中的<strong> </strong>"abc" 可以变为 "bcd"。开销为 3所以最大长度为 3。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "abcd", t = "cdef", maxCost = 3
<strong>输出:</strong>1
<strong>解释:</strong>s 中的任一字符要想变成 t 中对应的字符,其开销都是 2。因此最大长度为<code> 1。</code>
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = "abcd", t = "acde", maxCost = 0
<strong>输出:</strong>1
<strong>解释:</strong>a -> a, cost = 0字符串未发生变化所以最大长度为 1。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= s.length, t.length <= 10^5</code></li>
<li><code>0 <= maxCost <= 10^6</code></li>
<li><code>s</code> 和 <code>t</code> 都只含小写英文字母。</li>
</ul>