❇ largest-substring-between-two-equal-characters👌 O(N)❤️ Javascript🎯 Runtime 👀74.69%🕕 ++Explain
\nTime Complexity: O(N)\nSpace Complexity: O(1)\n\nvar maxLengthBetweenEqualCharacters = function (s) {\n    let highestLength = -1;\n    const obj = {};\n    f
\nTime Complexity: O(N)\nSpace Complexity: O(1)\n```\nvar maxLengthBetweenEqualCharacters = function (s) {\n    let highestLength = -1;\n    const obj = {};\n    for (let index = 0; index < s.length; index++) {\n        if (!obj[s[index]]) {\n            obj[s[index]] = [];\n        }\n        obj[s[index]].push(index);\n    }\n    for (const key in obj) {\n        if (obj[key].length > 1) {\n            const totalCharsInBetween = obj[key][obj[key].length - 1] - obj[key][0] - 1;\n            if (totalCharsInBetween > highestLength) {\n                highestLength = totalCharsInBetween;\n            }\n        }\n    }\n    return highestLength;\n};\n```\n\n![image](https://assets.leetcode.com/users/images/eb0cb370-02ba-4e21-bf1a-98b0751e55aa_1708452693.8144858.png)\n
['JavaScript']