JAVA O(n) time and O(1) space
```class Solution {\n    public int maxLengthBetweenEqualCharacters(String s) {\n        int maxLength = -1;\n        int[] indexStore = new int[26]; // Array w
```class Solution {\n    public int maxLengthBetweenEqualCharacters(String s) {\n        int maxLength = -1;\n        int[] indexStore = new int[26]; // Array with constant length of 26\n        Arrays.fill(indexStore, -1); //fill array with -1 for all not found chars\n        \n        for(int i = 0; i < s.length(); i++ ) {\n            if(indexStore[s.charAt(i) - \'a\'] != -1) { // check if char was previously found\n                int length = i - indexStore[s.charAt(i) - \'a\'] - 1;\n                maxLength = Math.max(maxLength, length);\n            } else {\n                indexStore[s.charAt(i) - \'a\'] = i; //put index of char replacing -1\n            }\n        }\n        \n        return maxLength;\n    }\n}
['Java']