32/32
Part 6 of 6 · Follow-upsCheck yourself
Check yourself
6 questions
  1. 1.A loop moves right over n entries, and an inner while loop moves left forward to shrink the window. In total, across the whole pass, how many times can the inner loop run?

  2. 2.sizes is sorted. With lo at the first index and hi at the last, sizes[lo] + sizes[hi] is bigger than the target. Which move is safe?

  3. 3.You keep a window of the last 2 log entries in a set, adding the key that enters and removing the key that leaves. The log is ana, ana, bo. What does the set hold for the window [ana, bo]?

  4. 4.A limiter allows 2 requests per 10 seconds per client, with a sliding window. A client's requests at 8 and 9 were allowed. What happens to its request at 10?

  5. 5.You want the longest stretch whose total is at most a budget, and the numbers can be negative. Why does grow-right, shrink-left stop working?

  6. 6.A limiter keeps a dict from each client to a deque of its request times, cleaning a deque when that client sends again. After a day it has seen 10 million clients, most of whom sent one request. What's wrong, and what fixes it?

Now the problem this lesson builds to: 31 Windows over a request logPractice it