Welcome to AlgoYogi!
🚀 Start Your Smart Coding Prep at 👉 https://algoyogi.io
We solve LeetCode 1624: Largest Substring Between Two Equal Characters using Python and a simple first-index map.
Goal: find the maximum length of a substring that lies strictly between two equal characters in s. If no such pair exists, return minus one.
Approach:
- Scan the string once while storing the first index seen for each character.
- When you see the same character again at index j, compute length as j minus first_index minus 1.
- Track the maximum over all repeats and return it. If nothing repeats, answer is minus one.
👉 Problem Link: https://leetcode.com/problems/largest-substring-between-two-equal-characters/description/
---
### ⏱ Timestamps
0:00 Introduction
0:20 Problem Statement
1:00 First-Index Mapping Approach
9:00 Python Code Walkthrough
12:00 Time and Space Complexity
---
### 💡 Why Watch?
- Clean O(n) one-pass solution with O(1) space for fixed alphabet
- Handles all repeats efficiently without nested loops
- Interview friendly and easy to reason about
#LeetCode #LargestSubstringBetweenEqualChars #Python #AlgoYogi #HashMap #Strings
Download
0 formats
No download links available.
LeetCode 1624 | Largest Substring Between Two Equal Characters | Python First-Index Trick | AlgoYogi | NatokHD