← Course home

Python reference · Reference

Backtracking and array patterns

Search a space of choices and recognize two-pointer, window, prefix-sum, and deque patterns.

ReferenceAbout 2 min

This page lists the library modules for Backtracking and array patterns. The lesson is Backtracking search.

This page is the module index for backtracking and array patterns.

  • backtracking/search.py — permutations, combinations, subsets, N-queens count.

Focused lessons

  • patterns/arrays.py — two pointers, sliding window, prefix sums, monotonic-queue window maximum.

Industry

A working engineer writes a backtracking search when a partial choice can be rejected, and a forward scan when the constraint is a window. The sliding-window maximum in this lesson keeps candidate indexes in a collections.deque. Python documents approximately O(1) appends and pops at either end, so each index can enter the deque and leave it once.

Implementation and tests Optional reference

Library code 2

  • bitsandbytes.backtracking.search
  • bitsandbytes.patterns.arrays

Use these references to compare the explanation with repository code and tests. A test link means it imports a lesson symbol; it does not by itself claim complete behavior coverage.