Question 1
For what purpose we can use sliding window technique in the context of algorithms?
To calculate all possible subsets of a given set
To optimize the time complexity of finding the maximum or minimum sum in a subarray
To implement dynamic programming efficiently
To iterate over all elements in an array in constant time
Question 2
Which of the following is the time complexity of using the sliding window technique to find the maximum sum of any subarray of size k in an array of size n?
O(n^2)
O(n)
O(k * n)
O(k)
Question 3
In the sliding window problem of finding the smallest substring containing all given characters, which type of window is used?
Fixed size
Variable size
Infinite window
Binary search window
Question 4
In a sliding window of size k, how do we efficiently update the window sum when moving right by one position?
Recompute sum from scratch
Subtract outgoing element, add incoming element
Multiply by k
Sort window elements
Question 5
You are given an array arr = [1, 2, 1, 2, 3] and k = 2.
What is the maximum number of distinct elements in any subarray of size k?
1
2
3
4
Question 6
You are given a string s = "aabcbcdbca".
What is the length of the smallest substring containing all distinct characters of s?
3
4
5
6
There are 6 questions to complete.