The variable window implementation of rolling max/min is O(n x w) rather than amortized O(n) with a deque based algorithm [here](https://stackoverflow.com/questions/12239042/spoj-arraysub-on-complexity-approach/12239580#12239580) is a possibility we could easily use the cython c++ impl of deque. [here](https://stackoverflow.com/a/48593365/644898) is a suggestion to use a heap.