1520. Maximum Number of Non-Overlapping Substrings
Description
**Input:** s = "adefaddaccc"
**Output:** ["e","f","ccc"]
**Explanation:** The following are all the possible substrings that meet the conditions:
[
"adefaddaccc"
"adefadda",
"ef",
"e",
"f",
"ccc",
]
If we choose the first string, we cannot choose anything else and we'd get only 1. If we choose "adefadda", we are left with "ccc" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose "ef" since it can be split into two. Therefore, the optimal way is to choose ["e","f","ccc"] which gives us 3 substrings. No other solution of the same number of substrings exist.ac
Previous1519. Number of Nodes in the Sub-Tree With the Same LabelNext1521. Find a Value of a Mysterious Function Closest to Target
Last updated