1520. Maximum Number of Non-Overlapping Substrings
https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings
Description
Given a string s
of lowercase letters, you need to find the maximum number of non-empty substrings of s
that meet the following conditions:
The substrings do not overlap, that is for any two substrings
s[i..j]
ands[k..l]
, eitherj < k
ori > l
is true.A substring that contains a certain character
c
must also contain all occurrences ofc
.
Find the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, *return the one with minimum total length.*It can be shown that there exists a unique solution of minimum total length.
Notice that you can return the substrings in any order.
Example 1:
Example 2:
Constraints:
1 <= s.length <= 10^5
s
contains only lowercase English letters.
ac
Last updated