1624. Largest Substring Between Two Equal Characters Easy

@problem@discussion
#Hash Table#String



1/**
2 * [1624] Largest Substring Between Two Equal Characters
3 *
4 * Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.
5 * A substring is a contiguous sequence of characters within a string.
6 *  
7 * Example 1:
8 * 
9 * Input: s = "aa"
10 * Output: 0
11 * Explanation: The optimal substring here is an empty substring between the two 'a's.
12 * Example 2:
13 * 
14 * Input: s = "abca"
15 * Output: 2
16 * Explanation: The optimal substring here is "bc".
17 * 
18 * Example 3:
19 * 
20 * Input: s = "cbzxy"
21 * Output: -1
22 * Explanation: There are no characters that appear twice in s.
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	1 <= s.length <= 300
28 * 	s contains only lowercase English letters.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/largest-substring-between-two-equal-characters/
34// discuss: https://leetcode.com/problems/largest-substring-between-two-equal-characters/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn max_length_between_equal_characters(s: String) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_1624() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.