Skip to content

Commit f73adae

Browse files
author
Joseph Luce
authored
Update 076_minimum_window_substring.md
1 parent e1c09b4 commit f73adae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

leetcode/hard/076_minimum_window_substring.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Once we have that, we need to basically prune it, remove the extra characters fr
1212
Finally, we keep repeating this until we reach the end.
1313
We can traverse the string via. two pointers, a left and right iterator.
1414
Right is bound within the given string S and left is bound within the substring created by the right pointer.
15+
This is an example of a sliding window.
1516

1617
To figure out if we have all the characters in this substring, we would have to count T via. a dictionary.
1718
This is our known count that is required for each substring.
@@ -28,7 +29,7 @@ When the question wants the actual substring and not a count, even using a deque
2829
So this implementation is technically **O(S * (S+T))** due to python.
2930

3031
When implementing these type of two pointer questions.
31-
I recommend to avoid using indexes as much as possible and use iterators.
32+
I recommend to **avoid using indexes as much as possible and use iterators**.
3233
It is very easy to get a one off error doing these and within a 30 minute timeframe, it is very risky.
3334
Just talk about using indexes instead and you will be fine.
3435

@@ -76,10 +77,10 @@ This will represent the number of unique valid characters of T.
7677
If T = 'abcc', then there are 3 keys in the dictionary.
7778
When ever we increment a key in the dictionary, we can then compare the dictionary T's count with dictionary S's count.
7879
If S's count equals exactly what T's count is, then we just got one of the 3 keys validated.
79-
If we decrement, and S's count is T's count-1, then we just unvalided one of those keys.
80+
If we decrement, and S's count is T's count-1, then we just unvalidated one of those keys.
8081

81-
This will remove the need to traverse all the keys whenever we need to validate the substring.
82-
Hence, this validation will run at O(1).
82+
This will remove the need to traverse all the keys whenever we need to revalidate the substring.
83+
Hence, this validation will run at O(1). String slicing will still slow us down however.
8384

8485
```
8586
from collections import defaultdict

0 commit comments

Comments
 (0)