Stressful
\nclass Solution {\n    public int maxLengthBetweenEqualCharacters(String s) {\n\t\tint mx = -1;\n\t\tchar[] arr = s.toCharArray() ;\n\t\tfor(int i=0 ;i<arr.len
```\nclass Solution {\n    public int maxLengthBetweenEqualCharacters(String s) {\n\t\tint mx = -1;\n\t\tchar[] arr = s.toCharArray() ;\n\t\tfor(int i=0 ;i<arr.length ;i++) {\n\t\t\tString str = s.substring(i+1) ;\n\t\t\tint temp = str.lastIndexOf(s.charAt(i)) ;\n\t\t\t\tmx = Math.max(mx ,  temp) ;\n\t\t}\n\t\treturn mx ;\n    }\n    \n}\n\n```\n\n/*\npublic int maxLengthBetweenEqualCharacters(String s) {\n\t\tint max = -1;\n\t\tfor (int i = 0; i < s.length(); i++) {\n\t\t\tint lastIndex= s.lastIndexOf(s.charAt(i));\n\t\t\tif(lastIndex != i) \n\t\t\t\tmax = Math.max(max, lastIndex - (i+1));\n\t\t}\n\t\treturn max;\n   }\n\n*/
[]