BEATS 100%
Code
# Code
```java []
class Solution {

    public int maxLengthBetweenEqualCharacters(String s) {
        int[] arr = new int[26];
        boolean[] seen = new boolean[26];
        int max = -1;
        for (int i = 0; i < s.length(); i++) {
            int pos = s.charAt(i) - 'a';
            if (seen[pos]) {
                max = Math.max(max, i - arr[pos] - 1);
            } else {
                seen[pos] = true;
                arr[pos] = i;
            }
        }
        return max;
    }
}
```
['Java']