Algorithms
Medium
2982
3266
Find Longest Special Substring That Occurs Thrice II
find-longest-special-substring-that-occurs-thrice-ii
"""
You are given a string s that consists of lowercase English letters.
A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.
A substring is a contiguous non-empty sequence of characters within a string.

Example 1:

Input: s = "aaaa"
Output: 2
Explanation: The longest special substring which occurs thrice is "aa": substrings "aaaa", "aaaa", and "aaaa".
It can be shown that the maximum length achievable is 2.

Example 2:

Input: s = "abcdef"
Output: -1
Explanation: There exists no special substring which occurs at least thrice. Hence return -1.

Example 3:

Input: s = "abcaba"
Output: 1
Explanation: The longest special substring which occurs thrice is "a": substrings "abcaba", "abcaba", and "abcaba".
It can be shown that the maximum length achievable is 1.


Constraints:

3 <= s.length <= 5 * 105
s consists of only lowercase English letters.
"""
class Solution:
    def maximumLength(self, s: str) -> int:
        
You are given a string s that consists of lowercase English letters.
A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.
Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.
A substring is a contiguous non-empty sequence of characters within a string.

Example 1:

Input: s = "aaaa"
Output: 2
Explanation: The longest special substring which occurs thrice is "aa": substrings "aaaa", "aaaa", and "aaaa".
It can be shown that the maximum length achievable is 2.

Example 2:

Input: s = "abcdef"
Output: -1
Explanation: There exists no special substring which occurs at least thrice. Hence return -1.

Example 3:

Input: s = "abcaba"
Output: 1
Explanation: The longest special substring which occurs thrice is "a": substrings "abcaba", "abcaba", and "abcaba".
It can be shown that the maximum length achievable is 1.


Constraints:

3 <= s.length <= 5 * 105
s consists of only lowercase English letters.


Please complete the code below to solve above prblem:
```python
class Solution:
    def maximumLength(self, s: str) -> int:
        
```

my_solution = Solution()

test_input = { "s": "aaaa" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "abcdef" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "abcaba" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "abcccccdddd" }
assert my_solution.maximumLength(**test_input) == 3

test_input = { "s": "acd" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "bad" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "bbc" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "ccc" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "cda" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "dab" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "ddd" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "eee" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "fff" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "hhh" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "jjj" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "kkk" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "lll" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "mmm" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "nnn" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "ooo" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "ppp" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "qqq" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "rrr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "sss" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "vvv" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "yyy" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "aaaj" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "aada" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "accc" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "auuu" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "azzz" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "bbbb" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "bbbr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "bccc" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "brrr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "cccc" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "clll" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "dbac" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "dddd" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "dddr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "dddu" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "dzzz" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "eeee" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "efda" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "efdc" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "ekkk" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "ggge" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "gggp" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "gggr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "gggy" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "guuu" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "hwww" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "hxxx" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "jjjj" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "jjjk" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "kkkk" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "lllm" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "lttt" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "mwww" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "nnnd" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "nnni" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "oooe" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "oooh" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "oooo" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "oooq" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "paaa" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "pggg" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "qooo" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "rrrr" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "smmm" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "thhh" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "tttt" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "uuuu" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "vppp" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "xqqq" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "xxxj" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "ysss" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "zzzz" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "aaaak" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "bbbjj" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "bbvvv" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "bfooo" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "buooo" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "cffff" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "cirrr" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "cwwwv" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "ddhhh" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "deeee" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "deiii" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "dtttk" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "eeeeq" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "eeekk" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "eesss" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "euuuu" }
assert my_solution.maximumLength(**test_input) == 2

test_input = { "s": "euylz" }
assert my_solution.maximumLength(**test_input) == -1

test_input = { "s": "fffhh" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "fpddd" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "gcccn" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "gtwww" }
assert my_solution.maximumLength(**test_input) == 1

test_input = { "s": "hcfff" }
assert my_solution.maximumLength(**test_input) == 1