Skip to content

Practice Select K Disjoint Special Substrings

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

Medium#3458
LeetCode Problem

Select K Disjoint Special Substrings

Problem Statement

Given s and k, determine whether k nonoverlapping special substrings can be selected. A special substring must be shorter than the entire string, and every character occurring inside it must have all its occurrences in s contained within that substring. Return whether such a selection is possible.

Source: Select K Disjoint Special Substrings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "abcdbaefab", k = 2
Output
true

# Example 2

Input
s = "cdefdc", k = 3
Output
false

# Example 3

Input
s = "abeabe", k = 0
Output
true

Constraints

2 <= n == s.length <= 5 * 10^4
0 <= k <= 26
s consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Select K Disjoint Special Substrings.

Review your practice with PhantomCodeAI

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