aboutsummaryrefslogtreecommitdiffstats
path: root/1624
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-31 03:12:42 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-31 03:12:42 +0000
commit6ff471410061b1d1a9f332402dd2db451d066ce4 (patch)
tree1ef3bfff597a369b3a90bd3f9481e528da9e1ffc /1624
parent1897 (diff)
downloadleetcode-6ff471410061b1d1a9f332402dd2db451d066ce4.tar.gz
leetcode-6ff471410061b1d1a9f332402dd2db451d066ce4.zip
1624
Diffstat (limited to '')
-rwxr-xr-x1624/main.py23
1 files changed, 23 insertions, 0 deletions
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()