代码拉取完成,页面将自动刷新
同步操作将从 小墨/力扣题库(完整版) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<p>Given two strings <code>s</code> and <code>t</code>, your goal is to convert <code>s</code> into <code>t</code> in <code>k</code><strong> </strong>moves or less.</p>
<p>During the <code>i<sup>th</sup></code> (<font face="monospace"><code>1 <= i <= k</code>) </font>move you can:</p>
<ul>
<li>Choose any index <code>j</code> (1-indexed) from <code>s</code>, such that <code>1 <= j <= s.length</code> and <code>j</code> has not been chosen in any previous move, and shift the character at that index <code>i</code> times.</li>
<li>Do nothing.</li>
</ul>
<p>Shifting a character means replacing it by the next letter in the alphabet (wrapping around so that <code>'z'</code> becomes <code>'a'</code>). Shifting a character by <code>i</code> means applying the shift operations <code>i</code> times.</p>
<p>Remember that any index <code>j</code> can be picked at most once.</p>
<p>Return <code>true</code> if it's possible to convert <code>s</code> into <code>t</code> in no more than <code>k</code> moves, otherwise return <code>false</code>.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> s = "input", t = "ouput", k = 9
<strong>Output:</strong> true
<b>Explanation: </b>In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> s = "abc", t = "bcd", k = 10
<strong>Output:</strong> false
<strong>Explanation: </strong>We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> s = "aab", t = "bbb", k = 27
<strong>Output:</strong> true
<b>Explanation: </b>In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length, t.length <= 10^5</code></li>
<li><code>0 <= k <= 10^9</code></li>
<li><code>s</code>, <code>t</code> contain only lowercase English letters.</li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。