# Sliding Window on Substring

For most substring problem, we are given a string and need to find a substring of it which satisfy some restrictions. A general way is to use a hashmap assisted with two pointers.

The general idea is that we can alternatively slide end and begin pointers and stop end once the substr between two pointers satisfies the requirement, then slide begin until breaks the requirement.

1. Find the first valid substring (move end pointer only)
2. Slide window to find the shortest valid substring (move both begin and end pointer)

When asked to find maximum substring, we should update maximum after the inner while loop to guarantee that the substring is valid. On the other hand, when asked to find minimum substring, we should update minimum inside the inner while loop.

Related problems:

#### Minimum Substring Contains Certain Target String Characters

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).

"CDOBACODEBANC","AABC" -> "ACODEBA"