C++ || 0ms || Short & concise solution || Constant space
Please do upvote if you liked my approach. It is a great motivation to write more such solutions :)\n\nclass Solution {\npublic:\n    int maxLengthBetweenEqualC
**Please do upvote if you liked my approach. It is a great motivation to write more such solutions :)**\n```\nclass Solution {\npublic:\n    int maxLengthBetweenEqualCharacters(string s) \n    {\n        int hash[26] = {0};\n        int ans = -1;\n        \n        for(int i=0; i<s.length(); i++)\n        {\n            if(hash[s[i]-\'a\'] == 0)\n                hash[s[i]-\'a\'] = i+1;\n            else\n                ans = max(ans, i-hash[s[i]-\'a\']);\n        }\n        \n        return ans;\n    }\n};\n```
['C', 'C++']