What if the window size varies? At position , valid where bounds depend on . If is non-decreasing, the left side still slides right. Pop expired elements from front as usual.
If is non-decreasing, new elements can be added in order. Standard monotonic queue works. If bounds are arbitrary, monotonic queue doesn't directly apply. Consider segment trees or other structures.