466. Count The Repetitions Hard

@problem@discussion
#String#Dynamic Programming



1/**
2 * [466] Count The Repetitions
3 *
4 * We define str = [s, n] as the string str which consists of the string s concatenated n times.
5 * 
6 * 	For example, str == ["abc", 3] =="abcabcabc".
7 * 
8 * We define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1.
9 * 
10 * 	For example, s1 = "abc" can be obtained from s2 = "ab<u>dbe</u>c" based on our definition by removing the bolded underlined characters.
11 * 
12 * You are given two strings s1 and s2 and two integers n1 and n2. You have the two strings str1 = [s1, n1] and str2 = [s2, n2].
13 * Return the maximum integer m such that str = [str2, m] can be obtained from str1.
14 *  
15 * Example 1:
16 * Input: s1 = "acb", n1 = 4, s2 = "ab", n2 = 2
17 * Output: 2
18 * Example 2:
19 * Input: s1 = "acb", n1 = 1, s2 = "acb", n2 = 1
20 * Output: 1
21 *  
22 * Constraints:
23 * 
24 * 	1 <= s1.length, s2.length <= 100
25 * 	s1 and s2 consist of lowercase English letters.
26 * 	1 <= n1, n2 <= 10^6
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/count-the-repetitions/
32// discuss: https://leetcode.com/problems/count-the-repetitions/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn get_max_repetitions(s1: String, n1: i32, s2: String, n2: i32) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_466() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.