Skip to content
CodeItRaw
Path

Binary search, walking from both ends and sliding windows over ordered data.

Key ideas

  • On sorted data, walk in from both ends: move the right one if the sum is too big, the left one if too small.
  • Sliding window: grow the right edge, shrink the left when the rule breaks. Each element enters once and leaves once.
  • Binary search halves the range every step: log n reads.

Pattern

lo = 0
for hi in range(len(values)):
    # add values[hi] to the window
    while window_is_invalid():
        # remove values[lo]
        lo += 1

Finish these first:Arrays

Lessons

Each lesson explains one idea from zero and ends with a few tasks. Lessons open in order; the explanation can be read at any time.

  1. 01

    Sorted data is a gift

    0/2 tasks

  2. 02

    Walking in from both ends

    0/3 tasks

  3. 03

    Walking two lists together

    0/2 tasks

  4. 04

    The sliding window

    0/3 tasks

Boss

  • 05

    No Repeats

    Function

  • The boss opens when every lesson of the topic is finished. Solve it too and the topic is complete, and the topics after it open.