int maxLengthBetweenEqualCharacters(string s) {
unordered_map<char,int>m;
int maxi=-1;
for(int i=0;i<s.size();i++)
{
if(m.find(s[i])!=m.end())
{
maxi=max(maxi,i-m[s[i]]-1);
}
else
m[s[i]]=i;
}
return maxi;
}
int maxLengthBetweenEqualCharacters(string s) {
int ans = -1;
for (int left = 0; left < s.size(); left++)
for (int right = left + 1; right < s.size(); right++)
if (s[left] == s[right])
ans = max(ans, right - left - 1);
}