Tap here to switch tabs
Problem
Submissions

Problem: Strange Printer

med
30 min
Try to solve the Strange Printer problem.

Statement

You are given a string s and a printer that works in turns. In one turn, the printer selects a contiguous segment of s and prints a single lowercase letter across the entire segment. Any characters already present in that segment are overwritten.

Return the minimum number of turns needed to print s starting from an initially empty string.

Note: The printer can overwrite previously printed characters.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Strange Printer

med
30 min
Try to solve the Strange Printer problem.

Statement

You are given a string s and a printer that works in turns. In one turn, the printer selects a contiguous segment of s and prints a single lowercase letter across the entire segment. Any characters already present in that segment are overwritten.

Return the minimum number of turns needed to print s starting from an initially empty string.

Note: The printer can overwrite previously printed characters.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of lowercase English letters.