Lessons 26–30 · About 60 min per lesson

Mixed practice and solution review

Select a method from the constraints and problem properties and verify it on small data.

Lesson breakdown

  1. Lesson 26

    Read past problems and mark signals for intervals, monotonicity and connectivity.

  2. Lesson 27

    Write a small reference solution for tasks from two categories.

  3. Lesson 28

    Implement efficient versions and compare using random small inputs and fixed boundaries.

  4. Lesson 29

    Document each solution’s assumptions and worst-case cost.

  5. Lesson 30

    Review one mistaken choice and add a distinguishing counterexample.

Worked example

Can the nonnegative-array bounded-window technique be used on [4,-4,4] with limit 4?

How to solve it

This input contains a negative value. Removing a negative can raise the sum, and extending into one can lower it, so the needed monotonicity is absent. On [5,-4] with limit 4, shrinking early loses the length-2 answer.

Assignment

Solve the range-counting problem Breed Counting and the directed traversal problem Moocast. For each, submit your first idea, implementation and small-case checks.

Check your result

Include an edge case, explain both time costs and state the assumption behind each improved solution.