Data Structures19 sections · 729 units
Open in Course

Quiz: Sliding Window

Time complexity

Check Your Understanding

Why is the variable-size sliding window O(n) even though it has a nested while loop?

  1. A.Each element is added and removed at most once total across all iterations
  2. B.The while loop runs at most log(n) times per iteration
  3. C.The inner loop skips most elements
  4. D.It's actually O(n²), not O(n)
Start the roadmap to answer the quizzes and solve the challenges