3760. Maximum Substrings With Distinct Start Medium
1/**
2 * [3760] Maximum Substrings With Distinct Start
3 *
4 * You are given a string s consisting of lowercase English letters.
5 * Return an integer denoting the maximum number of <span data-keyword="substring-nonempty">substrings</span> you can split s into such that each substring starts with a distinct character (i.e., no two substrings start with the same character).
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">s = "abab"</span>
10 * Output: <span class="example-io">2</span>
11 * Explanation:
12 *
13 * Split "abab" into "a" and "bab".
14 * Each substring starts with a distinct character i.e 'a' and 'b'. Thus, the answer is 2.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">s = "abcd"</span>
19 * Output: <span class="example-io">4</span>
20 * Explanation:
21 *
22 * Split "abcd" into "a", "b", "c", and "d".
23 * Each substring starts with a distinct character. Thus, the answer is 4.
24 * </div>
25 * <strong class="example">Example 3:
26 * <div class="example-block">
27 * Input: <span class="example-io">s = "aaaa"</span>
28 * Output: <span class="example-io">1</span>
29 * Explanation:
30 *
31 * All characters in "aaaa" are 'a'.
32 * Only one substring can start with 'a'. Thus, the answer is 1.
33 * </div>
34 *
35 * Constraints:
36 *
37 * 1 <= s.length <= 10^5
38 * s consists of lowercase English letters.
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/maximum-substrings-with-distinct-start/
44// discuss: https://leetcode.com/problems/maximum-substrings-with-distinct-start/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn max_distinct(s: String) -> i32 {
50 0
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_3760() {
62 }
63}
64Back
© 2026 bowen.ge All Rights Reserved.