664. Strange Printer Hard

@problem@discussion
#String#Dynamic Programming



1/**
2 * [664] Strange Printer
3 *
4 * There is a strange printer with the following two special properties:
5 * 
6 * 	The printer can only print a sequence of the same character each time.
7 * 	At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters.
8 * 
9 * Given a string s, return the minimum number of turns the printer needed to print it.
10 *  
11 * Example 1:
12 * 
13 * Input: s = "aaabbb"
14 * Output: 2
15 * Explanation: Print "aaa" first and then print "bbb".
16 * 
17 * Example 2:
18 * 
19 * Input: s = "aba"
20 * Output: 2
21 * Explanation: Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character 'a'.
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= s.length <= 100
27 * 	s consists of lowercase English letters.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/strange-printer/
33// discuss: https://leetcode.com/problems/strange-printer/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn strange_printer(s: String) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_664() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.