Data Structures19 sections · 729 units
Open in CourseQuiz: Sliding Window
Time complexity
Check Your Understanding
Why is the variable-size sliding window O(n) even though it has a nested while loop?
- A.Each element is added and removed at most once total across all iterations
- B.The while loop runs at most log(n) times per iteration
- C.The inner loop skips most elements
- D.It's actually O(n²), not O(n)