3557. Find Maximum Number of Non Intersecting Substrings Medium
1/**
2 * [3557] Find Maximum Number of Non Intersecting Substrings
3 *
4 * You are given a string word.
5 * Return the maximum number of non-intersecting <span data-keyword="substring-nonempty">substrings</span> of word that are at least four characters long and start and end with the same letter.
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">word = "abcdeafdef"</span>
10 * Output: <span class="example-io">2</span>
11 * Explanation:
12 * The two substrings are "abcdea" and "fdef".
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">word = "bcdaaaab"</span>
17 * Output: <span class="example-io">1</span>
18 * Explanation:
19 * The only substring is "aaaa". Note that we cannot also choose "bcdaaaab" since it intersects with the other substring.
20 * </div>
21 *
22 * Constraints:
23 *
24 * 1 <= word.length <= 2 * 10^5
25 * word consists only of lowercase English letters.
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/find-maximum-number-of-non-intersecting-substrings/
31// discuss: https://leetcode.com/problems/find-maximum-number-of-non-intersecting-substrings/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn max_substrings(word: String) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_3557() {
49 }
50}
51Back
© 2026 bowen.ge All Rights Reserved.