1593. Split a String Into the Max Number of Unique Substrings
1593. Split a String Into the Max Number of Unique Substrings
Description
Given a strings
, return the maximum number of unique substrings that the given string can be split into.
You can split strings
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 .
A substring is a contiguous sequence of characters within a string.
Example 1:
1 | Input: s = "ababccc" |
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.
Example 2:
1 | Input: s = "aba" |
Explanation:
One way to split maximally is [‘a’, ‘ba’].
Example 3:
1 | Input: s = "aa" |
Explanation:
It is impossible to split the string any further.
Constraints:
1 <= s.length<= 16
s
contains only lower case English letters.
Hints/Notes
- 2024/10/01
- back tracking
- No solution from 0x3F
Solution
Language: C++
1 | class Solution { |