100%beats
\nclass Solution {\npublic:\n    int maxLengthBetweenEqualCharacters(string s) {\n        vector> mp(26, {-1, -1});\n        int n = s.size();\n\n        for (i
\nclass Solution {\npublic:\n    int maxLengthBetweenEqualCharacters(string s) {\n        vector<pair<int, int>> mp(26, {-1, -1});\n        int n = s.size();\n\n        for (int i = 0; i < n; i++) {\n            if (mp[s[i] - \'a\'].first == -1)\n                mp[s[i] - \'a\'].first = i;\n            mp[s[i] - \'a\'].second = i;\n        }\n\n       \n\n        int res = -1;\n        for (int i = 0; i < 26; i++) {\n            if (mp[i].first == -1 || mp[i].second == -1)\n                continue;\n            else {\n                res = max(res, mp[i].second - mp[i].first-1);\n            }\n        }\n        return res;\n    }\n};\n\n```
['C++']