Skip to content

Practice Maximum Number of Non-Overlapping Substrings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1520
LeetCode Problem

Maximum Number of Non-Overlapping Substrings

Problem Statement

Choose as many nonempty, mutually nonoverlapping substrings of s as possible. If a chosen substring contains a character, it must include every occurrence of that character in s. Among maximum-count choices, minimize the total chosen length; that minimum-length choice is unique. Return its substrings in any order.

Source: Maximum Number of Non-Overlapping Substrings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "adefaddaccc"
Output
["e","f","ccc"]

# Example 2

Input
s = "abbaccd"
Output
["d","bb","cc"]

Constraints

1 <= s.length <= 10^5
s contains only lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Maximum Number of Non-Overlapping Substrings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.