1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/出现在屏幕上的字符串序列 [find-the-sequence-of-strings-appeared-on-the-screen].html
2024-11-07 00:20:26 +08:00

53 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串 <code>target</code></p>
<p>Alice 将会使用一种特殊的键盘在她的电脑上输入 <code>target</code>,这个键盘<strong> 只有两个 </strong>按键:</p>
<ul>
<li>按键 1在屏幕上的字符串后追加字符 <code>'a'</code></li>
<li>按键 2将屏幕上字符串的 <strong>最后一个 </strong>字符更改为英文字母表中的 <strong>下一个</strong> 字符。例如,<code>'c'</code> 变为 <code>'d'</code><code>'z'</code> 变为 <code>'a'</code></li>
</ul>
<p><strong>注意</strong>,最初屏幕上是一个<em></em>字符串 <code>""</code>,所以她<strong> 只能</strong> 按按键 1。</p>
<p>请你考虑按键次数 <strong>最少</strong> 的情况,按字符串出现顺序,返回 Alice 输入 <code>target</code> 时屏幕上出现的所有字符串列表。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">target = "abc"</span></p>
<p><strong>输出:</strong> <span class="example-io">["a","aa","ab","aba","abb","abc"]</span></p>
<p><strong>解释:</strong></p>
<p>Alice 按键的顺序如下:</p>
<ul>
<li>按下按键 1屏幕上的字符串变为 <code>"a"</code></li>
<li>按下按键 1屏幕上的字符串变为 <code>"aa"</code></li>
<li>按下按键 2屏幕上的字符串变为 <code>"ab"</code></li>
<li>按下按键 1屏幕上的字符串变为 <code>"aba"</code></li>
<li>按下按键 2屏幕上的字符串变为 <code>"abb"</code></li>
<li>按下按键 2屏幕上的字符串变为 <code>"abc"</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">target = "he"</span></p>
<p><strong>输出:</strong> <span class="example-io">["a","b","c","d","e","f","g","h","ha","hb","hc","hd","he"]</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= target.length &lt;= 400</code></li>
<li><code>target</code> 仅由小写英文字母组成。</li>
</ul>