I wasn’t able to get the advantage of using deque instead of using bruteforce approach. The time complexity remains the same for both cases I guess.
Doubt in the video
brute force has time complexity : o(n*K) k is the window size
while deque method time complexity is O( n )
Time Complexity: It seems more than O(n) at first look. If we take a closer look, we can observe that every element of array is added and removed at most once. So there are total 2n operations.
Auxiliary Space: O(k)
1 Like
Oh yes. My bad!
In deque approach I missed the subtle point.
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.