Sliding Window
Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides.
Use AND, OR, XOR, and shifts to solve problems directly on the binary representation of numbers, often in O(1) space.
Find the one number in an array that does not appear exactly twice.
Count how many bits are set to 1 in the binary form of a number.
For every number up to n, count how many bits are set to 1 in its binary form.
Find the one number missing from a list containing n distinct numbers from 0 to n.
Reverse the bits of a 32-bit unsigned integer.
Check whether an integer is a power of two using a bit trick.
Count the number of differing bits between two integers.
Find the one number in an array that does not appear exactly three times.
Add two integers together without using the + or - operators.
Compute the bitwise AND of every number in a range from m to n.
Find the two numbers that appear exactly once in an array where every other number appears twice.
Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides.
Scan a sorted array or string from both ends at once to find pairs, remove duplicates, or reverse data in O(n).
Cut a sorted range in half on every step to find a value or boundary in O(log n) instead of checking one by one.
Explore as far as possible down one path before backtracking, used to walk trees, graphs, and grids.
Explore level by level from a starting point, the go-to way to find the shortest path in an unweighted graph.
Break a problem into overlapping subproblems and reuse their answers to avoid recomputing the same work.