blob: c4cddf8bbad06482dea4b239c2df1fc8bb715992 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/bin/env python
class Solution:
def maxLengthBetweenEqualCharacters(self, s: str) -> int:
result = -1
for c in s:
if s.count(c) > 1:
result = max(result, s.rfind(c) - 1 - s.find(c))
return result
def main():
solution = Solution()
print(solution.maxLengthBetweenEqualCharacters("aa"))
print(solution.maxLengthBetweenEqualCharacters("abca"))
print(solution.maxLengthBetweenEqualCharacters("cbzxy"))
print(solution.maxLengthBetweenEqualCharacters("mgntdygtxrvxjnwksqhxuxtrv"))
if __name__ == "__main__":
main()
|