Search for a command to run...
You are given a string S.
You need to split it into the minimum number of contiguous substrings such that:
Each substring must contain no repeating characters
Every character of the original string must be used
Substrings must remain contiguous
Your task is to return the minimum number of substrings required.
A single string S
A single integer representing the minimum number of valid substrings
1≤∣S∣≤1051 \le |S| \le 10^51≤∣S∣≤105
Input:
abacOutput:
2Explanation: One valid split is: ab | ac
"ab" → all unique
"ac" → all unique
So minimum substrings = 2
Example 1
abac2Example 2
aabbccddeeff6abac
2