1593. Split a String Into the Max Number of Unique Substrings Medium

@problem@discussion
#Hash Table#String#Backtracking



1/**
2 * [1593] Split a String Into the Max Number of Unique Substrings
3 *
4 * Given a string s<var>,</var> return the maximum number of unique substrings that the given string can be split into.
5 * You can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique.
6 * A substring is a contiguous sequence of characters within a string.
7 *  
8 * Example 1:
9 * 
10 * Input: s = "ababccc"
11 * Output: 5
12 * Explanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Splitting like ['a', 'b', 'a', 'b', 'c', 'cc'] is not valid as you have 'a' and 'b' multiple times.
13 * 
14 * Example 2:
15 * 
16 * Input: s = "aba"
17 * Output: 2
18 * Explanation: One way to split maximally is ['a', 'ba'].
19 * 
20 * Example 3:
21 * 
22 * Input: s = "aa"
23 * Output: 1
24 * Explanation: It is impossible to split the string any further.
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	
30 * 	1 <= s.length <= 16
31 * 	
32 * 	
33 * 	s contains only lower case English letters.
34 * 	
35 * 
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/
40// discuss: https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45    pub fn max_unique_split(s: String) -> i32 {
46        0
47    }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55
56    #[test]
57    fn test_1593() {
58    }
59}
60


Back
© 2025 bowen.ge All Rights Reserved.