Algorithms
Medium
2981
3267
Find Longest Special Substring That Occurs Thrice I
find-longest-special-substring-that-occurs-thrice-i
"""
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 <= 50
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 <= 50
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": "aaa" }
assert my_solution.maximumLength(**test_input) == 1

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

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

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

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

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

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

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

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

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

test_input = { "s": "hhh" }
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": "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": "xxx" }
assert my_solution.maximumLength(**test_input) == 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test_input = { "s": "rzzz" }
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": "unnn" }
assert my_solution.maximumLength(**test_input) == 1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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