码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Strange Printer 奇怪的打印机

时间:2018-01-20 11:06:05      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:second   inpu   nim   desc   UI   new   str   over   div   

 

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 奇怪的打印机

标签:second   inpu   nim   desc   UI   new   str   over   div   

原文地址:https://www.cnblogs.com/grandyang/p/8319913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!