hardDynamic ProgrammingString 0 views

Strange Printer

There is a strange printer with the following two special properties: Given a string s, return the minimum number of turns the printer needed to print it.

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

Given a string s, return the minimum number of turns the printer needed to print it.

Strange Printer diagram

Example 1

Input: s = "aaabbb"

Output: 2

Explanation: Print "aaa" first and then print "bbb".

Example 2

Input: s = "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'.

Constraints

  • 1 <= s.length <= 100
  • s consists of lowercase English letters.

Hints

No hints yet.

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.