educative.io

Is this problem related to the lesson?

The problem doesn’t seem to have anything to do what I am being asked to do in the solution. Is it just me not understanding anything? The solution talks about deque, for example. This is not mention in the lesson anywhere.


Course: Grokking Coding Interview Patterns in Python - Learn Interactively
Lesson: Find Maximum in Sliding Window - Grokking Coding Interview Patterns in Python

Hi @Amilkar_Herrera we will review the cards in the “Figure it out!” section. You were asking about the word Deque .deque is the abbreviated name of a data structure, “doubly-ended queue”, that supports O(1) append and pop operations. We are using Deque because as the sliding window changes at every iteration, with one element being added to it, and another being removed, anything other than O(1) for append and pop operations would be too costly.

Hello @Amilkar_Herrera

I hope you are fine,

The problem talks about a sliding window. We will be using a deque as a sliding window. As mentioned by my colleague earlier, a deque is a doubly ended queue. We can enqueue and dequeue from both ends of the queue. As shown in the illustration, a slidiing window also needs to be able to enqueue and dequeue at both ends. This data structure is best to be used as a sliding window as we don’t need to create any extra functions, and it is the easiest to understand.

As always, we appreciate our valued users reaching out to us. Therefore, please write to us if you have any further queries, concerns, or suggestions in general.

We hope you enjoy your experience with us at Educative! Happy learning!