You are given the following array arr = [1, 2, 3, 4, 5, 6]
and the window size k = 3
. Initially, the start = 0
and end = 2
(the window includes elements from index 0 to 2). After processing this window, what is the next action taken by the sliding window algorithm?
Add the element at index 3
to the window and remove the element at index 0
Add the element at index 4
to the window and remove the element at index 1
Add the element at index 4
to the window and keep the element at index 2
Add the element at index 3
to the window and keep the element at index 0
This question is part of this quiz :
Quiz on Sliding window Technique for DSA