Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3090 - Maximum Length Substring With Two Occurrences\.

    Easy

    Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.

    Example 1:

    Input: s = "bcbbbcba"

    Output: 4

    Explanation:

    The following substring has a length of 4 and contains at most two occurrences of each character: <code>"bcbb<ins>bcba</ins>"</code>.

    Example 2:

    Input: s = "aaaa"

    Output: 2

    Explanation:

    The following substring has a length of 2 and contains at most two occurrences of each character: <code>"<ins>aa</ins>aa"</code>.

    Constraints:

    • 2 &lt;= s.length &lt;= 100

    • s consists only of lowercase English letters.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer maximumLengthSubstring(String s)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait