pyassistant

Partition string into minimum substrings with all unique characters

Given a string s, partition it into the minimum number of contiguous substrings such that each substring contains only unique characters (no character repeats inside a substring). Return the list of substrings (in order) forming such a partition. If multiple partitions with the same minimal number exist, return the one produced by the greedy left-to-right strategy (which is optimal). Constraints: s consists of ASCII letters and/or digits; 0 <= len(s) <= 10^5. Examples: - s = "abac" -> ["ab", "ac"] - s = "bbbb" -> ["b", "b", "b", "b"]

Example:

Input:
("abac",)
Output:
["ab", "ac"]

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.