[LeetCode] Strange Printer 奇怪的打印机

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Strange Printer 奇怪的打印机相关的知识,希望对你有一定的参考价值。

 

There is a strange printer with the following two special requirements:

  1. The printer can only print a sequence of the same character each time.
  2. At each turn, the printer can print new characters starting from and ending at any places, and will cover the original existing characters.

 

Given a string consists of lower English letters only, your job is to count the minimum number of turns the printer needed in order to print it.

Example 1:

Input: "aaabbb"
Output: 2
Explanation: Print "aaa" first and then print "bbb".

 

Example 2:

Input: "aba"
Output: 2
Explanation: Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character ‘a‘.

 

Hint: Length of the given string will not exceed 100.

 

s

 

 

 

以上是关于[LeetCode] Strange Printer 奇怪的打印机的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 664. Strange Printer (DP)

Delphi XE8 Printe VCL和DocumentProperties奇怪的问题

UVA10519 Really Strange大数+递推

国赛 strange_int

ruby sidetiq_strange.rb

AtCoder - 3939 Strange Nim