🚀 Swift | Hash Table | Time: O(n) | Space: O(n)
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    func maxLengthBetweenEqualCharacters(_ s: String) -> Int {\n        var res = -1\n        var charsAndIndexs: [String.Element: [Int]] = [:]\n\n        for (currentIndex, char) in s.enumerated() {\n            if let indexs = charsAndIndexs[char], let charIndex = indexs.first {\n                let currentDistance = currentIndex - charIndex - 1\n                res = max(res, currentDistance)\n            } else {\n                charsAndIndexs[char] = [currentIndex]\n            }\n        }\n        \n        return res\n    }\n}\n```
['Hash Table', 'Swift']