Computer Science: Algorithms Workbook

Sliding Window

Max Value

For the window, we will be using a dequeue data structure, for it takes O(1) for both popping from the start and the end. The main idea is to keep the highest element at the window[0] position.

For this algorithm, we would have two loops:

  1. Initialise the dequeue structure

📚 References

Expand…

1

I am using this as a workbook for this course.

2

Computer Science Distilled book.