From 6ff471410061b1d1a9f332402dd2db451d066ce4 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Sat, 30 Dec 2023 22:12:42 -0500 Subject: 1624 --- 1624/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 1624/main.py diff --git a/1624/main.py b/1624/main.py new file mode 100755 index 0000000..c4cddf8 --- /dev/null +++ b/1624/main.py @@ -0,0 +1,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() -- cgit v1.2.3