JAVA Solution Explained in HINDI
https://youtu.be/RWjF8Gwi6X0\n\nHAPPY NEW YEAR IN ADVANCE \uD83D\uDC96\uD83D\uDC96\nFor explanation, please watch the above video and do like, share and subscri
https://youtu.be/RWjF8Gwi6X0\n\n**HAPPY NEW YEAR IN ADVANCE** \uD83D\uDC96\uD83D\uDC96\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F\n\nSubscribe link:- https://youtube.com/@quantumCode7?si=NzjWYmiCbqfFBUJE\n\nSubscribe Goal:- 100\nCurrent Subscriber:- 42\n\n# Code\n```\nclass Solution {\n    public int maxLengthBetweenEqualCharacters(String s) {\n\n        Map<Character, Integer> firstOccur = new HashMap<>();\n        int ans = -1;\n\n        for(int i = 0; i < s.length(); i++) {\n\n            if(firstOccur.containsKey(s.charAt(i))) {\n                ans = Math.max(ans, i - firstOccur.get(s.charAt(i)) - 1);\n            }\n            else {\n                firstOccur.put(s.charAt(i), i);\n            }\n        }\n        return ans;   \n    }\n}\n```
['Java']