FastPrepMaximum Unique Substring Split
Problems/Maximum Unique Substring Split

Maximum Unique Substring Split

The Walt Disney Company logoThe Walt Disney Company● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The author identifies an original LeetCode 1593 screen and says candidates had to devise and run tests; no follow-up was reported.

The phonetic number is matched to the official task title. The report omits inputs and bounds; this practice contract uses 1 to 16 lowercase English letters and returns the count.

The judged task matches the named exercise at about 90%.

Split the entire string s into nonempty contiguous substrings such that no two chosen substrings have the same value. Return the maximum possible number of substrings.

Keep characters in their original order and use every character exactly once. Only the maximum count is returned; different optimal partitions are equally valid.

Function

maxUniqueSplit(s: String) → int

Examples

Example 1

s = "abca"return = 3

One optimal partition is ["a","b","ca"], with three distinct pieces. Four pieces would repeat "a", so the maximum is 3.

Example 2

s = "aaaa"return = 2

Use ["a","aaa"] or ["aaa","a"]. Three distinct positive substring lengths would need at least six characters, so the maximum is 2.

Constraints

  • 1 <= s.length <= 16
  • Every character of s is a lowercase English letter.

More The Walt Disney Company problems

  • Find All Paths for a Name in a File SystemPHONE SCREEN · Seen Nov 2026
  • Resizable Array-Backed Integer SetPHONE SCREEN · Seen Sep 2026
  • Shortest Path with Directional Move CostsPHONE SCREEN · Seen Sep 2026
All The Walt Disney Company interview questionsSee The Walt Disney Company hiring insights
Saved
class Solution {
    public int maxUniqueSplit(String s) {
        // Write your code here
    }
}
Checking account…