java.lang.Object
g3001_3100.s3090_maximum_length_substring_with_two_occurrences.Solution

public class Solution extends java.lang.Object
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: “bcbbbcba.

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: aaaa”.

Constraints:

  • 2 <= s.length <= 100
  • s consists only of lowercase English letters.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    maximumLengthSubstring(java.lang.String s)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maximumLengthSubstring

      public int maximumLengthSubstring(java.lang.String s)