A dynamic-size sliding window expands and contracts based on a condition. Move the right pointer to expand the window until a condition is violated, then move the left pointer to shrink the window until the condition is restored. At each valid state, update the result. For example, to find the longest substring without repeating characters, expand right to include new characters. When a duplicate is found, shrink from the left until the duplicate is removed. The left pointer never moves backward, so both pointers traverse the array at most once each, giving O of n total time.