← Sliding Window Quiz: all 8 questions
Sliding Window Quiz · Question 6 of 8
What is the time complexity of the variable sliding window, even with the inner while loop?
What is the time complexity of the variable sliding window, even with the inner while loop?
- A.O(n²)
- B.O(n)
- C.O(n log n)
- D.O(k·n)
Answer & explanation
Correct answer: O(n)
Each element enters the window once and leaves at most once, so total work is O(n).
Can you get the rest right without peeking?
Take the timed Sliding Window Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →