1624. Largest Substring Between Two Equal Characters

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1624

class Solution:
    def maxLengthBetweenEqualCharacters(self, s: str) -> int:
        d = {}
        res = -1
        for i, c in enumerate(s):
            if c in d:
                res = max(res, i - d[c] - 1)
            else:
                d[c] = i
        return res