1668. Maximum Repeating Substring Easy

@problem@discussion
#String#String Matching



1/**
2 * [1668] Maximum Repeating Substring
3 *
4 * For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.
5 * Given strings sequence and word, return the maximum k-repeating value of word in sequence.
6 *  
7 * Example 1:
8 * 
9 * Input: sequence = "ababc", word = "ab"
10 * Output: 2
11 * Explanation: "abab" is a substring in "<u>abab</u>c".
12 * 
13 * Example 2:
14 * 
15 * Input: sequence = "ababc", word = "ba"
16 * Output: 1
17 * Explanation: "ba" is a substring in "a<u>ba</u>bc". "baba" is not a substring in "ababc".
18 * 
19 * Example 3:
20 * 
21 * Input: sequence = "ababc", word = "ac"
22 * Output: 0
23 * Explanation: "ac" is not a substring in "ababc". 
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= sequence.length <= 100
29 * 	1 <= word.length <= 100
30 * 	sequence and word contains only lowercase English letters.
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/maximum-repeating-substring/
36// discuss: https://leetcode.com/problems/maximum-repeating-substring/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn max_repeating(sequence: String, word: String) -> i32 {
42        0
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_1668() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.