The sliding window approach is greedy because it always tries to expand the window as much as possible while the window remains valid. Once the window becomes too large (i.e., it breaks the constraint, for example, when the number of replacements exceeds k in Leetcode 424, we shrink it just enough to make it valid again.