3090. Maximum Length Substring With Two Occurrences Easy

@problem@discussion
#Hash Table#String#Sliding Window



1/**
2 * [3090] Maximum Length Substring With Two Occurrences
3 *
4 * Given a string s, return the maximum length of a <span data-keyword="substring">substring</span> such that it contains at most two occurrences of each character.
5 *  
6 * <strong class="example">Example 1:
7 * <div class="example-block">
8 * Input: <span class="example-io">s = "bcbbbcba"</span>
9 * Output: <span class="example-io">4</span>
10 * Explanation:
11 * The following substring has a length of 4 and contains at most two occurrences of each character: "bcbb<u>bcba</u>".</div>
12 * <strong class="example">Example 2:
13 * <div class="example-block">
14 * Input: <span class="example-io">s = "aaaa"</span>
15 * Output: <span class="example-io">2</span>
16 * Explanation:
17 * The following substring has a length of 2 and contains at most two occurrences of each character: "<u>aa</u>aa".</div>
18 *  
19 * Constraints:
20 * 
21 * 	2 <= s.length <= 100
22 * 	s consists only of lowercase English letters.
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/
28// discuss: https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn maximum_length_substring(s: String) -> i32 {
34        0
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_3090() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.