290. Partition into Substrings with Unique Characters

HardStringString

Given a string s, partition it into the minimum number of contiguous substrings such that no character repeats within any single substring. Return the number of substrings in this greedy partition.

Input: A quoted string s.

Output: Integer — number of substrings.

Examples

Example 1
Input: "abac"
Output: 2
Explanation: 'aba' repeats 'a' so split: 'ab','ac'.
Example 2
Input: "abc"
Output: 1
Explanation: All unique.
Example 3
Input: "aaa"
Output: 3
Explanation: Each 'a' its own part.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →