Skip to content

Commit ff34172

Browse files
Refactor loop to use enumerate for clarity.
Replaced manual index-based iteration with enumerate in the sliding window implementation. This improves code readability by simplifying access to both index and character in the loop.
1 parent 075f66f commit ff34172

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Sliding Window/minimum_window_substring.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ def min_window(s: str, t: str) -> str:
2626
window_counts = defaultdict(int)
2727
window = ''
2828

29-
for right in range(n):
29+
for right, char in enumerate(s):
3030
# Add one character from the right to the window
31-
char = s[right]
3231
window_counts[char] += 1
3332
window += char
3433

0 commit comments

Comments
 (0)