Smallest Subarray to Sort in Every Sliding Window
For each window, compare it with its sorted copy; the first and last disagreeing offsets bound the shortest segment that repairs the whole window.
For each window, compare it with its sorted copy; the first and last disagreeing offsets bound the shortest segment that repairs the whole window.