|
| 1 | +<h2><a href="https://leetcode.com/problems/strange-printer/">664. Strange Printer</a></h2><h3>Hard</h3><hr><p>There is a strange printer with the following two special properties:</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>The printer can only print a sequence of <strong>the same character</strong> each time.</li> |
| 5 | + <li>At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters.</li> |
| 6 | +</ul> |
| 7 | + |
| 8 | +<p>Given a string <code>s</code>, return <em>the minimum number of turns the printer needed to print it</em>.</p> |
| 9 | + |
| 10 | +<p> </p> |
| 11 | +<p><strong class="example">Example 1:</strong></p> |
| 12 | + |
| 13 | +<pre> |
| 14 | +<strong>Input:</strong> s = "aaabbb" |
| 15 | +<strong>Output:</strong> 2 |
| 16 | +<strong>Explanation:</strong> Print "aaa" first and then print "bbb". |
| 17 | +</pre> |
| 18 | + |
| 19 | +<p><strong class="example">Example 2:</strong></p> |
| 20 | + |
| 21 | +<pre> |
| 22 | +<strong>Input:</strong> s = "aba" |
| 23 | +<strong>Output:</strong> 2 |
| 24 | +<strong>Explanation:</strong> Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character 'a'. |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p> </p> |
| 28 | +<p><strong>Constraints:</strong></p> |
| 29 | + |
| 30 | +<ul> |
| 31 | + <li><code>1 <= s.length <= 100</code></li> |
| 32 | + <li><code>s</code> consists of lowercase English letters.</li> |
| 33 | +</ul> |
0 commit comments