1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/奇怪的打印机 [strange-printer].html
2022-03-29 12:43:11 +08:00

35 lines
994 B
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>有台奇怪的打印机有以下两个特殊要求:</p>
<ul>
<li>打印机每次只能打印由 <strong>同一个字符</strong> 组成的序列。</li>
<li>每次可以在从起始到结束的任意位置打印新字符,并且会覆盖掉原来已有的字符。</li>
</ul>
<p>给你一个字符串 <code>s</code> ,你的任务是计算这个打印机打印它需要的最少打印次数。</p>
&nbsp;
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "aaabbb"
<strong>输出:</strong>2
<strong>解释:</strong>首先打印 "aaa" 然后打印 "bbb"。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = "aba"
<strong>输出:</strong>2
<strong>解释:</strong>首先打印 "aaa" 然后在第二个位置打印 "b" 覆盖掉原来的字符 'a'。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 100</code></li>
<li><code>s</code> 由小写英文字母组成</li>
</ul>