Five patterns that need no extra memory at all — two integers and the array you were handed. Where each one applies, why it is linear, and the one line in the last one that everybody writes backwards.
Both pointers move the same way and the gap between them is the answer. Four window shapes, plus the counting trick that turns “exactly K” into a subtraction because “exactly K” cannot be slid directly.
Precompute once, answer every range question in constant time — and the inverse trick almost nobody is taught, which applies an update to a whole range by writing two cells.
Finding a value in a sorted array is the least useful thing binary search does. The pattern that matters searches an answer space no one ever built, and it does not need a sorted array at all.
A stack that refuses to hold anything useless answers “what is the next bigger thing” for a whole array in one pass — and the same structure measures the largest rectangle in a histogram.
Counting without two hash lookups per item, the exact input size where Array.Sort stops preserving order, and the heap C# only got in .NET 6 — which most older C# contest code still works around.
The representation most C# solutions use is also why they time out. Then breadth-first search, depth-first search without the call stack, and the sort that detects a cycle for free.
Weights break BFS. Dijkstra fixes it, C#’s PriorityQueue has no DecreaseKey so you push duplicates instead, and when every edge is 0 or 1 the heap turns out to be pure overhead.
Not the theory — the five shapes that keep coming back, and the single loop direction that silently turns one of them into a completely different problem.
The part you only care about after a correct solution has already timed out. Reading input without allocating, the overflow C# will not warn you about, and why Console.WriteLine in a loop costs 400,000 writes.
C# does not ship the node type these problems assume, and LinkedList
Three recursive orders that differ by one line, the iterative version nobody can reconstruct under pressure, and why level-order needs one local variable rather than cleverness.
Almost every tree problem is one question — does this quantity travel down the tree or back up it? Path sums, the diameter that never touches the root, ancestors, and the BST check that everyone writes wrong the first time.
The whole family turns on one choice — sort by the start, or sort by the end. Merging wants one, the scheduling greedy wants the other, and the code looks almost the same either way.
One template, five problems. Choose, explore, un-choose — and it is the un-choose that people leave out, because the code looks finished without it.
XOR to isolate the value that appears once, the BitOperations class most C# code never uses, and the shift that silently does nothing because the count wrapped.