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 += 1Finish 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.
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.