Given a string s, return the maximum length of a substring such that every character occurs at most 222 times within it.
s
Constraints:
2≤2 \leq2≤ s.length ≤100\leq 100≤100
s.length
s consists only of lowercase English letters.
Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Maximum Length Substring With Two Occurrences
For the input xy, what is the maximum length of a substring in which every character occurs at most (2) times?
xy
(1)
(2)
(0)
(3)
We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.
Implement your solution in the following coding playground.